I'm new to PHP, and would like to know if there is a code snippet for emailing a lost password to a subcriber

First, we must assume that you are currently storing the 
username/login, password and the email address in a mySQL table. Once
we know the username/login, we simply use that to locate the password
and utilize the mail() function to send it.

Your snippet would be something like this:

$result = mysql_query ("SELECT password,email FROM yourtable
WHERE username = '$username'");
if ($myrow = mysql_fetch_array($result)) {
$mailaddress = $myrow["email"];
$subject = "Important Message"; // don't say password in subject
$message = "Your password is: " . $myrow["password"] ;
$header = "Ancillary message or other stuff";
mail($mailaddress,$subject,$message,$header);
}

Hope this is helpful.

Was this answer helpful?

 Print this Article

Also Read

How to redirect from php page to another php page?

For redirecting, you can use the PHP header() function like so : header("Location:...

How to refresh a page?

...

Why i couldn't fetch my variable from the form?

Register_Globals directive is set to OFF because of potential security issues.  PHP has this...

What is the essence of PHP encryption(using crypt(),mcrypt(),etc)if data on transit isn't safe?

The apathetic response is, of course, "there is no point." If you allowed a login over normal...

I'm new to PHP, where should I start?

Well, try this.The official PHP web site as a lot of useful information:   ...