I'm not sure if this is a duplicate, but I couldn't find anything about this. I have a simple query put in for a login, when the username and password are both correct it will run the IF finding ofcourse 1 row. Yet when I get the password or username wrong it should run the ELSE. Sadly this is not the case and I get a white screen without any errors.
Code:
$result = $dbcon->query("SELECT * FROM PT_USERS WHERE Username = '$gebruiker' AND Password = '$wachtwoord'");
while($row = $result->fetch_assoc()) {
if($result->num_rows == 1) {
$_SESSION['PT_USERS'] = $row["Username"];
$_SESSION['PT_CONFIRM'] = $row["Confirmed"];
header("Location: ../");
}
else {
$result = $dbcon->query("SELECT * FROM PT_USERS WHERE Username = '$gebruiker'");
if($result->num_rows == 1) {
echo '<script>alert("Het wachtwoord klopt niet met dit gebruikersnaam!");</script>';
header("Location: ../");
}
else {
echo '<script>alert("Geen account gevonden!");</script>';
header("Location: ../");
}
}
}
I've been looking on how to fix this, but I can't seem to find anything. Any luck you guys can help?
Thanks!