I have a script that I am working on in PHP that logs IP Address's of visters that go to that specific page. This is just a prototype. The script that I have concocted is working, but when it creates the TXT file containing the IP's it only does one line. How can I make it keep adding a line for every visitor regardless if they are a repeat visitor. I am not really sure how to go about that part, I am new to PHP.
Here is what I have so far:
<?PHP $ip = getenv("REMOTE_ADDR"); $date = date("d") . " " . date("F") . " " . date("Y"); $intofile = $ip . "n" . $date; $hfile = fopen("ip-address.txt", "w"); fwrite($hfile, $intofile); fclose($hfile); ?> <!DOCTYPE html> <html language="en-us"> <head> <title>IP Address Logging Software</title> <link rel="stylesheet" type="text/css" href="Source/Stylesheet/DefaultPage.css" /> <link rel="stylesheet" type="text/css" href="Source/Stylesheet/DefaultPage.css" /> <link rel="stylesheet" type="text/css" href="Source/Stylesheet/DefaultPage.css" /> <script type="text/javascript" src="Source/Javascript/DefaultScript.css"></script> <script type="text/javascript" src="Source/Javascript/DefaultScript.css"></script> <script type="text/javascript" src="Source/Javascript/DefaultScript.css"></script> </head> <body language="en-us"> <?PHP $ip=$_SERVER['REMOTE_ADDR']; echo "<strong>Your IP Address <em>$ip</em> Has Been Logged</strong>"; ?> </body> </html>
access.logand filter by url. much faster and no extra implementation necessary. don't usegetenvthis is deprecated use$_SERVER