Jump to content

strchr


etsted

Recommended Posts

this script is supposed to only register a user if he has not been on my website, but this script keep on adding the IP of a person all the time

 

$filref = fopen("tekst.txt", "a");$ip = $_SERVER['SERVER_ADDR'];$les_fil = fread($filref, filesize("tekst.txt"));if(!strchr($les_fil, $ip) ){ fwrite($filref, $ip);}else{ echo "cannot register more";}

Link to comment
Share on other sites

when using a, it sets the pointer to the end of the file.

http://www.php.net/manual/en/function.fopen.php

 

so fread is always checking at the end of the file.

 

you might want to review the answers here

http://stackoverflow.com/questions/4103287/read-a-plain-text-file-with-php

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...