Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/55983-check-if-line-in-txt-exists/
Share on other sites

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.