A
Anonymous
Guest
how would i go about creating a form for a user to input their password then php/sql sending the username and password back to them?
Very simple. If the password in the DB is encoded, you will need to reset the password before it is sent out.
PASSWORD(str)
Calculates a password string from the plaintext password str. This is the function that is used for encrypting MySQL passwords for storage in the Password column of the user grant table:
mysql> SELECT PASSWORD('badpwd');
-> '7f84554057dd964b'
PASSWORD() encryption is non-reversible. PASSWORD() does not perform password encryption in the same way that Unix passwords are encrypted. See ENCRYPT(). Note: The PASSWORD() function is used by the authentication system in MySQL Server, you should NOT use it in your own applications. For that purpose, use MD5() or SHA1() instead. Also see RFC-2195 for more information about handling passwords and authentication securely in your application.
$name = $row['first_name'];
$username = $row['username'];
function generatePassword ($length = 8)
{
global $password;
$password = "";
$possible = "0123456789abcdefghijklmnpqrstuvwxyz";
$i = 0;
while ($i < $length) {
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
if (!strstr($password, $char)) {
$password .= $char;
$i++;
}
}
return $password;
}
generatePassword();
echo $password;
$setpassword = md5($password);
$sqlstatement = "UPDATE user_info SET password = '$setpassword' WHERE email = '$email'";