I cant figure out why it wont write the client IP address to the file, everything else works.
<?php
$myFile = "ips.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
fwrite($fh, $_SERVER['REMOTE_HOST']);
fclose($fh);
echo $_SERVER['REMOTE_ADDR'];
?>
Thanks in advance.
Maybe
fwrite($fh, $_SERVER['REMOTE_ADDR']);?Why do you think that if
echo $_SERVER['REMOTE_ADDR'];works,fwrite($fh, $_SERVER['REMOTE_HOST']);should too?Try
echo $_SERVER['REMOTE_HOST'];first and see if it outputs something.My guess: just change
_HOSTto_ADDRin fwrite as I said in the beginning.