Re: password retrevial code needed?

From: Date: Mon, 05 Aug 2002 04:55:45 +0000
Subject: Re: password retrevial code needed?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-111134@lists.php.net to get a copy of this message
Short answer: Select the username/password from the table 'users' where the email address matches the one submitted via a form, then use mail() to send that info to them. Long answer: Let's say they submit their email address via a POSTed form. then the script which process' that POSTed form would do the following: <? // UNTESTED CODE $user_email = $_POST['email']; // the POSTed email address $sql = "SELECT username, password FROM users_table WHERE email_address='{$user_email}'"; $result = mysql_query($sql); if(!$result) { echo "your email address didn't match any of our records"; } else { $myrow = mysql_fetch_array($result); $subject = "your password reminder from mysite.com"; $message = "Your username/password for mysite.com is {$myrow['username']}/{$myrow['password']}"; $headers = "From: passwords@mysite.com"; mail($user_email, $subject, $message, $headers); } ?> Tweak to suit your needs. If you wanted them to submit their username, rather than their email address, just swap a few things around. Regards, Justin French on 05/08/02 2:37 PM, Deadsam (deadsam@sympatico.ca) wrote: > I'm trying to add a password retrvial code to my forum, but so far it's > eluding me, all I want it to grab from the database is the username, email > and password, then email it to the person. Sounds simple but for some reason > it refuses to work for me. > Any help would be appreciated very much > Thank you in advance > Deadsam > >

« previous php.general (#111134) next »