Page 1 of 1
Forgot my Password feature
Posted: Sun Mar 16, 2003 9:04 pm
by jparsons
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.
Posted: Sun Mar 16, 2003 9:31 pm
by Mr. Tech
Are you using a MySQL database?
Posted: Sun Mar 16, 2003 10:20 pm
by oldtimer
How are you storing their password? Plaintext or encrypted? If it is encrypted then you really can not email it to them. Instead they should fill out a forgoten pw form and then have a random pw generated and emailed to them. Of course this is all if you are using a Database.
Posted: Sun Mar 16, 2003 10:31 pm
by jparsons
Im using MySQL with non-encrypted passwords.
Posted: Sun Mar 16, 2003 11:06 pm
by Mr. Tech
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:
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
}
?>
Hope that helps!