In the following program the first strpos() function is working just just fine when searching for a matching email address in the text file as long as it's on the first line but the second entry it jumps streight to the else clause and echos "Unknown user name" even though that email is on line to of the file. Any ideas?
<?php
$email = $_POST['email'];
$psswd = $_POST['psswd'];
echo "The email address is $email<br>";
echo "The password is $psswd<br><br>";
$file = fopen("./accounts.txt", 'r+') or die("Failed to open file");
while(!feof($file))
{
$line = fgets($file);
if(strpos($line, "$email") !== false)
{
echo "There was a match";
if(strpos($line, "$psswd") !== false)
{
echo "<br>Password is a match.";
$db = new SQLite3('./users.db', SQLITE3_OPEN_READWRITE);
if(!$db)
{
echo "Could not open/access DB";
}
else
{
echo "<br>DB is good!";
}
break;
}
else
{
echo "<br>Invalid Password!";
}
}
else
{
echo "Unknown user name";
//header("localhost/ET/password/:unknown.html");
break;
}
//echo "$line<br>";
}
//$line = fgets(preg_match($email, '$file'));
fclose($file);
?>