raiyen90 Posted June 18, 2007 Share Posted June 18, 2007 Ok so i have a hit counter on my site, but the problem is people going and reloading the page over and over, so i need to make it so it grabs their ip and sends that to a seperate text file. Thats easy but i cannot find anything on searching lines of a text file for a certain string. sooooo if u could help me?? maybe thanx Quote Link to comment https://forums.phpfreaks.com/topic/55983-check-if-line-in-txt-exists/ Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 elaborate more of it plss Quote Link to comment https://forums.phpfreaks.com/topic/55983-check-if-line-in-txt-exists/#findComment-276509 Share on other sites More sharing options...
raiyen90 Posted June 18, 2007 Author Share Posted June 18, 2007 ok <?php $filename = "hits.txt"; $handle = fopen($filename, "r"); $views = fread($handle, filesize($filename)); fclose($handle); $handle = fopen($filename, "w"); $views++; fwrite($handle, $views); fclose($handle); echo $views; php?> there is my code i have currently, i want it to check if the ip address exists in any lines of a txt file, if not grab the ip and save it to a text file (on a new line of course). But if the ip does exist to just skip the whole code of my counter where it writes the number to my hits.txt hope that sounds better? Quote Link to comment https://forums.phpfreaks.com/topic/55983-check-if-line-in-txt-exists/#findComment-276510 Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 http://www.php.net/manual/en/function.fopen.php Quote Link to comment https://forums.phpfreaks.com/topic/55983-check-if-line-in-txt-exists/#findComment-276515 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.