The text file is set up like this:
user:pass:first_name:last_name
With multiple users listed.
I got the function mostly written, however It only returns true if you enter the first user's information. If you enter the second user's information, it will match it on the second loop, but still return false. Any help on this would be great, Thank you. I posted my function below.
Code: Select all
<?php
function getLogin($username, $password)
{
$fp_open=fopen("registered_users.txt", "r");//read file in
if(!$fp_open)
{
echo "Sorry, I failed and cannot find this file. Please try again later!<br/>";
exit();
}
if($fp_open)
{
while(!feof($fp_open))
{
$user_info=fgets($fp_open);
for($i=0; $i<count($user_info); $i++)
{
$line=explode(":", $user_info);
$user= $line[0];
$pass=$line[1];
if($username==$user && $password==$pass)
{
return true;
break;
}
else
{
return false;
}
}
}
}
}
?>