Issues and Improvements:
-
Password Parameter Issue:
-
The script tries to fetch the password from the URL (
$_GET['passsword']
), which might not be secure. Typically, password reset systems involve generating a unique token rather than directly manipulating passwords in the URL. This would be a more secure way to reset the password.
-
-
SQL Injection Protection:
-
The current query is vulnerable to SQL injection because the user input (
email
) is being inserted directly into the SQL query without sanitization. Use prepared statements to avoid this risk.
-
-
Email Sending with PHPMailer:
-
You're using both the PHP
mail()
function and PHPMailer. Since you're already including PHPMailer, it would be more consistent to use it for sending the email instead of mixing it with the PHPmail()
function.
-
-
Error Reporting:
-
The error reporting (
error_reporting(0)
) is suppressing any potential errors. It's better to log or display errors in a development environment and suppress them in production.
-
-
Password Update Flow:
-
The password update part of the flow (
$query2 = mysqli_query($con,"UPDATE password SET passsword='$password' WHERE email='$email'")
) might not be working because the Apassword
column in the database might have different naming or formatting (you should confirm column names and avoid directly setting a password like this).
-
Updated PHP Code:
Key Changes:
-
Prepared Statements: Used for querying the database to avoid SQL injection.
-
Token Generation: Instead of passing the password directly, a unique token is generated and stored in the database. This will be used to reset the password.
-
PHPMailer: Replaced the
mail()
function with PHPMailer for a more consistent and reliable email sending process. -
Error Reporting: Adjusted error reporting for better debugging.
Next Steps:
-
Implement a
resetpassword.php
page to handle the password reset using thetoken
parameter. -
Ensure your database stores the reset token and has an expiration time for better security.
Kindly help on forgotpass.php ()orgot Password Recovery using PHP and MySQL as per your video https://www.youtube.com/watch?v=GiHaXbBTsL4&list=PLI1ax0C4di-EvOd404xK6xmD6Dkujc8KE&index=5&pbjreload=101
Following your code mine Says Email sent but I dont receive any email