diff --git a/.gitignore b/.gitignore index a0f0e53..d0ee3b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -.vscode -.DS_Store +venv/ +__pycache__/ +*.pyc diff --git a/AnswerSecurityQuestions.php b/AnswerSecurityQuestions.php new file mode 100644 index 0000000..7c78db4 --- /dev/null +++ b/AnswerSecurityQuestions.php @@ -0,0 +1,87 @@ +'; + } + } + + // Fetch security questions from the database for display + $sql = "SELECT question1, question2 FROM password_recovery_security_questions WHERE email = '$email'"; + $result = mysqli_query($con, $sql); + + if ($row = mysqli_fetch_assoc($result)) { + // Display the questions in a form + echo'


'; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + if (isset($error_message)) { + echo ''; // Display error message + } + + //echo '
'; + echo '
'; + echo 'Answer Your Security Questions.'; + + // Question 1 + echo '
'; + echo ''; + echo ''; + echo '
'; + echo'
'; + + // Question 2 + echo '
'; + echo ''; + echo ''; + echo '
'; + + echo ''; + echo '
'; + echo '
'; // Close container + } else { + echo '
'; + } +} else { + header("Location: RecoverPassword.php"); // Redirect if session data is missing + exit; +} + +mysqli_close($con); +?> diff --git a/Header.php b/Header.php index 0733467..718a6b5 100644 --- a/Header.php +++ b/Header.php @@ -1,3 +1,8 @@ + + My courses "; } ?> diff --git a/recover_password.php b/RecoverPassword.php similarity index 75% rename from recover_password.php rename to RecoverPassword.php index 7eb2656..373eaba 100644 --- a/recover_password.php +++ b/RecoverPassword.php @@ -15,11 +15,9 @@ include 'Header.php';
Recover password - Student number -
Email
- +
diff --git a/ResetPassword.php b/ResetPassword.php new file mode 100644 index 0000000..aa17765 --- /dev/null +++ b/ResetPassword.php @@ -0,0 +1,78 @@ +Password must be at least 8 characters long and include uppercase and lowercase letters, numbers, and special characters.'; + } elseif ($new_password !== $confirm_password) { + echo '
Passwords do not match. Please try again.
'; + } else { + $hashed_password = password_hash($new_password, PASSWORD_ARGON2ID); + $user_id = $_SESSION['user_id']; + + $stmt = $con->prepare("UPDATE users_table SET Password = ? WHERE email = ? AND user_id = ?"); + $stmt->bind_param("sss", $hashed_password, $email, $user_id); + + if ($stmt->execute()) { + echo '
Password reset successfully. You can now log in with your new password.
'; + unset($_SESSION['user_id']); // Clear user_id after successful password reset + header("Location: index.php"); + } else { + error_log("Error updating password for user ID: $user_id"); + echo '
An error occurred. Please try again later.
'; + } + $stmt->close(); + } + } +} + +// Display the reset password form +echo ' +


+
+
+
+
+
+ Reset Your Password
+ New Password + +
+ Confirm New Password + +
+ +
+
+