I am building a login mask for a website. And I ran into a strange problem which I don't understand. I have a table with one entry (admin) and I am trying to validate the input from a login form. I tested everything and the problem seems to occur in my validate function. my table:
My validate function:
function validateAnmeldung($usermail, $password){
$conn = connectDB();
$sql = "SELECT id FROM anmeldung WHERE email = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $usermail);
$stmt->execute();
$userID = $stmt->get_result();
if(empty($userID)){
return false;
}
$sql2 = "SELECT passwort FROM anmeldung WHERE id = ?";
$stmt2 = $conn->prepare($sql2);
$stmt2->bind_param("i", $userID);
$stmt2->execute();
$actualPassword = $stmt2->get_result();
if($password == $actualPassword){
return true;
}
else{
return false;
}
}
Here some information: the parameter $usermail and $password are correct. The $userID which I am getting from my DB is correct. It just seems like the password which I am getting from my DB is incorrect. BUT if I execute the sql statement in the console, I get the right password. I copied this password and wrote the following line:
if($actualPassword == '4735ef749cdac8ff5f8b182e9c479d780ef0dca7') return true;
and it returned false. Any ideas? kind regards