Code: Select all
john:527bd5b5d689e2c32ae974c6229ff785
nick:e10adc3949ba59abbe56e057f20f883e
For some reason, when someone logs in, it allways sais the username/password is incorect. Heres the part of the code that authenticates the user:
Code: Select all
function check_pass($login, $password) {
global $password_file;
if(!$fh = fopen($password_file, "r")) { die("<P>Could Not Open Password File"); }
$match = 0;
$password = md5($password);
while(!feof($fh)) {
$line = fgets($fh, 4096);
$user_pass = explode(":", $line);
if($user_pass[0] == $login) {
if(rtrim($user_pass[1]) == $password) {
$match = 1;
break;
}
}
}
if($match) {
return 1;
} else {
return 0;
}
fclose($fh);
}
and then:
Code: Select all
if(isset($checkpass))
{
if(check_pass($login, $password))
{
print("Thank you for logging in");
$valid = 1;
print("<p><a href = test.php>Whatever</a>");
} else
{
print("Username/password not correct, please try again<p>");
$valid = 0;
print_login_form();
}
}
Any ideas why it doesnt work?