Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
HI,
I am trying to make a password_forgot script with md5. The registrate script is made with md5 function, all passwords are stored in DB md5 encrypted. I made a script for users who forget there password, they can send a email and ask for there password. The script have to generate a new password and storen the password in DB md5 enscrypted, end then send a email to a user a normal password.
My registration script work like this:
$temppass = $password;
$password = md5($password);
And this is myn forgot_password.php script:Code: Select all
<?php
@mysql_connect(localhost,"xxxxx","xxxxxx");
@mysql_select_db("xxxxx_DB") or die( "<CENTER> The DB could not be found.");
if ($HTTP_POST_VARS['command'] == 'forgot' &&
strlen($_POST['email'] <= 50)) {
$email = addslashes($_POST['email']);
$query = "select * FROM users WHERE email = '$email'";
$result = mysql_query($query);
$num = mysql_numrows($result);
if ($num > 0) {
$alphanum =
array('a','b','c','d','e','f','g','h','i','j','k','m','n','o',
'p','q','r','s','t','u','v','x','y','z','A','B','C','D','E',
'F','G','H','I','J','K','M','N','P','Q','R','S','T','U',
'V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9');
srand((double)microtime()*1000000);
$chars = sizeof($alphanum);
$a = time();
mt_srand($a);
for ($i=0; $i < 6; $i++) {
$randnum = intval(mt_rand(0,56));
$password .= $alphanum[$randnum];
}
$sql = "UPDATE $users SET password='".md5($password)."', .temppass($password) = 1 WHERE users = '$email' en password = '$password'";
$result = mysql_query($sql);
$to = $_POST['email'];
$from = "xxxx@xxxx.xxx";
$subject = "New password";
$msg = <<< EOMSG
Your new password is:
$password
Please log in at this URL:
http://localhost/login.html
Then go to this address to change your password:
http://localhost/changepass.php
EOMSG;
$mailsend = mail("$to","$subject","$msg","From:
$from\r\nReply-To:xxxx@xxxx.xxx");
if ($email) {
echo "The information is been send succenfully; $email";
} else {
echo "Failes sending a email<br><br>";
}
} else {
echo "This email adress could not be found in DB.<br><br>";}
}
?>I am trying to figure it out, what is not working in forgot_password.php script . Can anyone help me with this problem?
Thanks in advance,
NAT
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]