Jump to content

Error comparing a line from a file with a string


pantinosm

Recommended Posts

Hi to everyone.

So, I have a little php code that reads line by line from a txt file, specifically i have 1 IP address for each line, and compares it with the current user's IP. It's like a little blacklist code. But it doesn't work. Can anyone see what i am doing wrong?


$file = fopen("ipblacklist.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
$ipblacklist='';
$refile='';
while(!feof($file))
  {
  if (fgets($file)== $_SERVER['REMOTE_ADDR'])
   	   $ipblacklist='error';
    	  
  $refile=fgets($file);
  }
fclose($file);

 

Thank you in advance

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.