This is login.php. A user enters a username and password on the previous page. Database stores information in the format "user|pass". Using the explode function to separate user and pass with "|".
$details[0] finds a match on the same line. But not for $details[1] even though the inputted data is correct with the actual .txt file.
$user = $_POST['user'];
$pass = $_POST['pass'];
$db = file("database.txt");
$valid = false;
foreach ($db as $person) {
$details = explode('|', $person);
if ($details[0] == $user && $details[1] == $pass) {
// Found a math to the database.
$valid = true;
break;
}
}
Why is this the case?
Thanks
Aucun commentaire:
Enregistrer un commentaire