D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
proc
/
self
/
root
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
forgot_password.php
back
Copy
<?php include "../config.php"; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Forgot Password</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; } form { max-width: 650px; background-color: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } label { display: block; margin-bottom: 8px; } input { width: 100%; padding: 10px; margin-bottom: 16px; box-sizing: border-box; } input[type="submit"] { background-color: #4caf50; color: #fff; cursor: pointer; } input[type="submit"]:hover { background-color: #45a049; } a { color: #1e88e5; } </style> </head> <body> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>"> <h2 style="text-align: center;">Forgot Password</h2> <?php // Check if the form is submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { // Get form data $email = $_POST["email"]; // Validate and sanitize email (add more validation if needed) $email = filter_var($email, FILTER_SANITIZE_EMAIL); // Check if the email exists in the database $sql = "SELECT id, username FROM users WHERE email = '$email'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // Generate a unique code (you can use a library for this) $resetCode = uniqid(); // Store the reset code in the database $userId = $result->fetch_assoc()["id"]; $updateSql = "UPDATE users SET reset_code = '$resetCode' WHERE id = $userId"; $conn->query($updateSql); // Send an email with the reset link to the user $resetLink = "http://bazmeasar.com/admin/reset_password.php?code=$resetCode"; $subject = "Password Reset"; $message = "Click the following link to reset your password: $resetLink"; // Use a library or mail function to send the email echo '<p style="color: green; text-align: center;">Password reset instructions sent to your email.</p>'; } else { echo '<p style="color: red; text-align: center;">Email not found.</p>'; } } ?> <label for="email">Email:</label> <input type="email" name="email" required> <input type="submit" value="Reset Password"> </form> </body> </html>