I am running a php script located at http://www.airsep.com/test/index.php4
. What this does is basically logs users information (IP address, User Agent, and Date) and writes it to a database. For some reason when I access this page, the information is not written on the first visit, I must refresh the page for the data to show up in the database. If I open a new browser window and input the URL, the same thing happens. Here is my php code:
$filename = "data.txt";
$ip = $_SERVER['REMOTE_ADDR'];
$useragent = $_SERVER['HTTP_USER_AGENT'
$date = date("F j, Y, g:i a");
$fh = fopen($filename, "a") or die("Could not open file!");
$data = $ip . "|" . $useragent . "|" . $date . "\n";
fwrite($fh , $data);
I am not sure what I am doing wrong.