I would like to track the IP address of visitors, and have found the following code example on this web page- http://www.willmaster.com/blog/statisti ... resses.php. The code is to be pasted into the html of the web page on which the IP tracking is to be implemented.
(edit-- I'll call this Code #1)
Code: Select all
<?php
$LogFileLocation = "iplog.txt";
$fh = fopen($_SERVER['DOCUMENT_ROOT'].$LogFileLocation,'at');
fwrite($fh,date('dMy H:i:s')."\t".$_SERVER['REMOTE_ADDR']."\t".$_SERVER['REQUEST_URI']."\n");
fclose($fh);
?>
(which I'll call Code #2)
Code: Select all
$ip = getenv("REMOTE_ADDR");
$log = "\n$ip";
$fa = fopen("login", "a");
$login = "$log";
fwrite($fa, $login);
fclose($fa);
Also, when I did the php code years ago, I noticed that I could not use the fopen command, it would never work (is this a GoDaddy issue?).
Anyway, what is the best way to create a log file of the IP addresses of all visitors to my web site?