I get the error:
Fatal error: Uncaught Error: Call to a member function LogInValidatePassword() on array in C:\xampp\htdocs\ProjectSouls\log-in.php:34
but unfortunately I can't find the problem with the code.
On line 34 the method LogInValidatePassword
of the object user
gets called. In this method I use password-verify($password, $hashed)
. I pass the Password from the $_POST and the Hash of the database entry, which got fetched in the array $fetched
.
//log-in.php
$post_userpass = filter_input(INPUT_POST,"user_name",FILTER_SANITIZE_SPECIAL_CHARS);
$fetched = $statement->fetch(PDO::FETCH_ASSOC);
/*Line 34->*/ if($user->LogInValidatePassword($post_userpass,$fetched['user_pass'])){
$user->LogIn($fetched);
}else{
$user->ShowErrorResponse();
}
//user.class.php
public function LogInValidatePassword($password, $hashed){
if(!password_verify($password ,$hashed)){
$this->errors[] = "Sie haben ein falsches Passwort eingegeben.";
return false;
}else{
return true;
}
}
Since I'm not using a whole array, but just a single value of it, I don't get where the problem might be.
// I looked through similiar posts but didn't find any relatable solution.
Thanks in advance.