I am writing php to verify login credentials where the credentials (user,pass) is stored in a txt file: The text file has an empty line at the end.
users.txt
BobRock123,password123
DouglasFerm553,secret642
SallyHomes,Yse3qs
Vinny893,street3r2
php
$userFile = fopen("users.txt", "r") or exit("Unable to open file!");
while (!feof($userFile) && fgets($userFile) != "")
{
     $line = explode(",", fgets($userFile));
     if ($username == $line[0] && $password == $line[1])
     {
          header("Location:  nextpage.php");
          exit;
     }
}
I am not able to redirect to nextpage.php even trying with matching username and passwords (all matching username and passwords fail).
If I replace the if line with if (true), I will be redirected, confirming that I am able to open my file.
