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