$mail->prepareResetEmail(); $mail->sentEmail(); SessionOperator::setNotification(SessionOperator::RESET_PASSWORD); HelperOperator::redirectTo("../index.php"); } else { // Create a session for not found email SessionOperator::setInputErrors(["email" => "Email could not be found in our records"]); // Create a session for the inputted email so that it can be recovered after the page reloads SessionOperator::setFormInput(["email" => $_POST["email"]]); HelperOperator::redirectTo("../views/forgot_password_view.php"); } } else { if (isset($_POST["changePassword"])) { // Retrieve Passwords $passwordFields = ["password1" => $_POST["password1"], "password2" => $_POST["password2"]]; $email = SessionOperator::getEmail(); $userDetails = QueryOperator::getAccountFromEmail($email); // Both passwords valid and match if (!ValidationOperator::hasEmtpyFields($passwordFields) && ValidationOperator::validPasswords($passwordFields["password1"], $passwordFields["password2"])) { QueryOperator::updatePassword($email, $passwordFields["password2"]); SessionOperator::deleteEmail(); SessionOperator::setNotification(SessionOperator::CHANGED_PASSWORD); // Send a password changed confirmation email to the user $mail = new Email($email, $userDetails["firstName"], $userDetails["lastName"]); $mail->preparePasswordConfirmEmail(); $mail->sentEmail(); HelperOperator::redirectTo("../index.php"); } else { SessionOperator::setFormInput($passwordFields); } HelperOperator::redirectTo("../views/change_password_view.php?email=" . $email);