Jump to content

trouble with code to remind password


cryptonim

Recommended Posts

hi i have a problem with the code to remind the user's password if their forget, the user enter their email address and get them on the mailbox, everything works, but in a place where it should be the password is blank.

Help please here's the code:

 

 

<?

 

include 'db.php';

// Conver to simple variables

 

 

switch($_POST['recover']){

default:

include 'lost_pw.html';

break;

 

case "recover":

recover_pw($_POST['email_address']);

break;

}

function recover_pw($email_address){

if(!$email_address){

echo "You forgot to enter your Email address !!<br />";

include 'lost_pw.html';

exit();

}

// quick check to see if record exists

$sql_check = mysql_query("SELECT * FROM users WHERE email_address='$email_address'");

$sql_check_num = mysql_num_rows($sql_check);

if($sql_check_num == 0){

echo "No records found matching your email address<br />";

include 'lost_pw.html';

exit();

}

// Everything looks ok, generate password, update it and send it!

 

 

 

$db_password = md5 ($password);

 

$to = "email";

$sql = mysql_query("UPDATE users SET password='$password_md5' WHERE email_address='$email_address'");

$headers = "From: [email protected]";

$subject = "Your Password at MyWebsite!";

$message = "Hi $username  your username and password is,

 

Username:$username

Password:$password

 

http://www.something.com/login_form.html

 

Thanks!

The Webmaster

 

This is an automated response, please do not reply!";

 

mail($email_address, $subject, $message, "From: [email protected]>\nX-Mailer: PHP/" . phpversion());

include 'password.html';

}

?>

Link to comment
https://forums.phpfreaks.com/topic/226670-trouble-with-code-to-remind-password/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.