I currently have it like this: <?php $filename = "hits.txt"; $file = file($filename); $file = array_unique($file); $hits = count($file); echo $hits; echo "$refer"; $fd = fopen ($filename , "r"); $fstring = fread ($fd , filesize ($filename)); fclose($fd); $fd = fopen ($filename , "w"); $fcounted = $fstring."IP: ".getenv("REMOTE_ADDR"); $refer = ' Referrer: ' . $_SERVER["HTTP_REFERER"] . "\n"; $fout= fwrite ($fd , $fcounted . $refer); fclose($fd); ?> PHP: When i go on it twice from my pc, this is exactly what it shows on the txt file: IP: 78.148.52.111 Referrer: youtube.com etc whereever user clicked. IP: 78.148.52.111 Referrer: youtube.com etc whereever user clicked. Code (markup): I basicly want it to do this: Unique hits: 43 IP: 78.148.52.111 Referrer: youtube.com etc where-ever user clicked. IP: 78.148.52.111 Referrer: youtube.com etc where-ever user clicked. Code (markup): Etc, thanks.
I think the problem here is,you have opened the file in write mode and written only the IP address and HTTP_REFERER. so it would display it only. if you want to display the hits you have to write it also in the file. Or if you want to uppend the file then you have to open it in w+ mode.