Code: Select all
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;
}
if i understand correctly, it opens the file, and gets the first line, username and password, but if theres nore than one line how can it get the correct combination?
say for example you have this in the passwd file:
nick:123456
jack:password
and the user enters the username as jack, how would it know that it has to get the second line?