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.

  • 10 Kunder som kunne bruge dette svar
Hjalp dette svar dig?

Relaterede artikler

I get an error 'Server.CreateObject Failed' when I try to use CDONTs. What can I do?

CDONTs is no longer supported on Windows 2003 server.  Microsoft introduced CDO back several...

Do you allow custom COM components?

Yes, we do allow Custom Components and we have to charge setup fee for your COM Components...

ASP to MSSQL connection

Before you can access your MS-SQL Server database from your ASP code , you need to connect to it...

How do I send email from ASP using SMTP Authentication?

Please note that our mail server is configured with Authentication. Below is the code snippet...

After I configure the custom error setting in the control panel, I still get the generic error page?

Custom error setting is a web server setting that sets your website Error Pages, but you can...