I am trying to send an email to user (using PHP Mailer) to recover the forgotten password using the following hyperlink attached to email:
$emailBody = ",<br><br><p>Click this link to recover your password<br><a
href='" . PROJECT_HOME . "reset_password.php?email=" . $user["email"] .
"'>" . PROJECT_HOME . "reset_password.php?email=" . $user["email"] . "</a>
<br><br></p>Regards,<br> Admin.</div>";
Ignore PROJECT HOME, it's local host.
This is working fine and suppose if the e-mail of the user is "ABC@gmail.com", the link sent to the user is "reset_passsword.php?email=ABC@gmail.com"
Now in the reset_password.php file, I've written the following php code but unfortunately the GET method isn't working. I tried echoing the email after getting it from $_GET but the output I get is: '..'
<?php
#include "dbConnection.php";
if(@$_GET['q']==1){
if(isset($_POST["reset-password"])) {
$con = mysqli_connect("localhost", "root", "", "project");
$email=@$_GET['email'];
echo "Email: '.$email.'";
echo $email;
$sql = "UPDATE user SET password = '" .
md5($_POST["member_password"]). "' WHERE email = $email";
$result = mysqli_query($con,$sql);
$success_message = "Password is reset successfully.";
}
}
?>
The form(in case anybody needs to see) is like this:
<form name="frmReset" id="frmReset" method="post"
action="reset_password.php?q=1" onSubmit="return
validate_password_reset();">
<h1>Reset Password</h1>
<?php if(!empty($success_message)) { ?>
<div class="success_message"><?php echo $success_message; ?><?php
echo '<br><br>' ?></div>
<?php } ?>
<div id="validation-message">
<?php if(!empty($error_message)) { ?>
<?php echo $error_message; ?><?php echo '<br><br>' ?>
<?php } ?>
</div>
<div class="field-group">
<div><label for="Password">Password</label></div>
<div>
<input type="password" name="member_password"
id="member_password" class="input-field"></div>
</div>
<div class="field-group">
<div><label for="email">Confirm Password</label></div>
<div><input type="password" name="confirm_password"
id="confirm_password" class="input-field"></div>
</div>
<div class="field-group">
<br> <div><input type="submit" name="reset-password"
id="reset-password" value="Reset Password" class="form-submit-button">
</div>
</div>
</form>