D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
process_reset_password.php
back
Copy
<?php include "../config.php"; ?> <?php session_start(); if ($_SERVER["REQUEST_METHOD"] == "POST") { // Retrieve form data $email = $_POST["email"]; $newPassword = $_POST["new_password"]; $confirmPassword = $_POST["confirm_password"]; // Validate password if ($newPassword != $confirmPassword) { echo "Password and confirm password do not match."; exit(); } // Hash the new password $hashedPassword = password_hash($newPassword, PASSWORD_DEFAULT); // Update the user's password in the database $stmt = $conn->prepare("UPDATE users SET password = ? WHERE email = ?"); $stmt->bind_param("ss", $hashedPassword, $email); $stmt->execute(); // Delete the reset code from the password_reset table $stmt = $conn->prepare("DELETE FROM password_reset WHERE email = ?"); $stmt->bind_param("s", $email); $stmt->execute(); echo "Password reset successfully! You can now <a href='login.php'>login</a> with your new password."; // Close the database connection $stmt->close(); $conn->close(); } else { // If the form was not submitted, redirect to the login page or show an error message header("Location: login.php"); exit(); } ?>