i asked for one, in the request, so then i thought i would learn on how to write information to a file, so now i have made a simple script that will record visitors IP, the time, and the date and there browser
<?php
//Set the date so we can store it in the text file.
$tdate = date("dS F Y h:i:s A");
//Check if there is a referer
if (!$HTTP_REFERER) { $HTTP_REFERER = "(NONE)"; }
//Store it in the counter.txt file ! DONT FORGET TO SET COUNTER.TXT CHMOD 777 !
$fp = fopen("counter.txt", "a");
$line = "IP Address: $REMOTE_ADDR - Date: $tdate - Referer: $HTTP_REFERER - Browser: $HTTP_USER_AGENT\n";
fwrite($fp, $line);
fclose($fp);
echo "Your IP is $REMOTE_ADDR<br>";
echo "the time is $tdate<br>";
echo "you are using $HTTP_REFERER";
?>
Hawkee is right, and second to that, if the site has high amounts of traffic the fopen will get errors because it will be locked by the same script running for another user. Use MySQL instead. Also why are you using the $HTTP_* variables? They are deprecated and have been replaced with the $_SERVER array.