(Linux)
In the following program I'm trying to process the file accounts.txt line by line searching for a match to the form supplied variable '$email'. The function fgets() is stepping though the file line by line correctly but my attempts at using preg_match() and or strpos() to determine if that line contains the string contained in '$email' have failed. Any ideas or suggestions? Thanks.
<?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(preg_match($email, $line))
{
echo "There was a match";
}
else
{
echo "There was not match";
}
//echo "$line<br>";
}
//$line = fgets(preg_match($email, '$file'));
fclose($file);
?>