Hello and thank you for your help in advance
I am currently creating a system where when a user sign-up he/she is registered in a database and their password is hashed. So far so good.
My issue appears when I attempt to log in after the creation. I have no issue loggin in with the hashed password (eg. $2y$10$1p7k9tPy.eU27q7rSHbeaer) but am unable to log in with the 'real' password (eg. playstation123) as it seems the system doesn't detect it.
if( count($user) == 0) {
$error_message = 'login+not+found';
header("Location: /login/error/$error_message");
exit();
}
so i receive an output in the browser with 'login+not+found'.
I believe the issue is related to this part:
if (strlen ($password) < 8 || strlen($password) > 25) {
$error_message = 'password+issue';
header ("Location: /signup/error/$error_message");
exit();
}
$repeatPassword = $_POST['repeat_password'];
if ( $repeatPassword !== $password){
$error_message = 'password+issue';
header("Location: /signup/error/$error_message");
exit();
}
try{
$q = $db->prepare('INSERT INTO users (name, last_name, age, email, password)
VALUES (:name, :last_name, :age, :email, :password)');
$hashedpassword = password_hash($password, PASSWORD_DEFAULT);
$q -> bindValue(':name', $firstName);
$q -> bindValue(':last_name', $lastName);
$q -> bindValue(':age', $age);
$q -> bindValue(':email', $email);
$q -> bindValue(':password', $hashedpassword);
$q->execute();
$user = $q->fetchAll();
$newUser = 'Signup+Successful';
header("Location: /login/success/$newUser");
exit();
} catch(PDOException $ex){
echo $ex;
}