Forgot my Password feature
Moderator: General Moderators
Forgot my Password feature
I am using Dreamweaver MX to build a PHP-based site. I have a login system in place. However, I would like to create a page that emails forgotten passwords to users. Any idea on where I might find code for this? I am somewhat novice with PHP, but good at adapting existing code.
Well, for example you could use this code. I just made it so that they enter their email and it it'll send the password to the email they filled out:
Hope that helps!
Code: Select all
<?php
if($get == "password") {
$getpass = mysql_fetch_array(mysql_query("select password from users where email=''$email"));
$yourname = "Your Name";
$youremail = "you@yourdomain.com";
$subject = "Your lost password";
message = "Your lost password is $getpass[password]";
@mail($youremail, $subject, $message, "From: "$yourname"<$youremail>\r\nReply-To: $youremail\r\nX-Sender:$yourname using $youremail\r\nReturn-Path: $youremail");
echo "Your password has been sent to your email";
}
else {
?>
<form action="getpass.php" method="get">
<input type="hidden" name="get" value="password">
Email: <input type="text" name="email"> <input type="submit" value="Get My Password!">
</form>
<?php
}
?>