} else { //if details are filled properly then run another query try { $query = $conn->prepare("SELECT userID FROM user WHERE email = :email"); $query->execute(array(':email' => $email)); //checks if there is an array of results $row = $query->fetch(PDO::FETCH_ASSOC); //fetches the results $userID = hash('sha512', $row['userID']); //encrypt the id if ($userID !== $currentID) { //if the current id != to the id from the db $error[] = "I think you have the wrong email!"; } else { //run the update method if ($reset->updateDetails($email, $password)) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) { $reset->login($email, $password); //if successful then login $reset->redirect('dashboard.php'); //and redirect to dashboard } } } } catch (PDOException $e) { echo $e->getMessage(); } } } } }