PHPJavascript

Web Development Guide – My Personal Library of Tutorials and Scripts

Generate random passwords and send email to user

June4

ForgotPassword. Generate a random password and notify users through email.

Generate random passwords and send email to user

You can use this feature in the forgotPassword scenarios

I have used random passwords in a scenario where a user forgets his password and receives a temporary new password.

Generate random password -rand()

$random=rand(1234,2343);
$password="mypass".$random;

Send email to user – mail()

$headers =”From: info@phpjavascript.com\n”; //from address
$headers .= “MIME-Version: 1.0\n”;
$headers .= “Content-type: text/html; charset=iso-8859-1 \n”;
$subject =”Password Recovery – Do Not Reply Back To This Email”;

$body=”<div align=center><br><br>—————————– Password Recovery——————————–<br><br><br><br>Your Temporary Password is: $password<br><br>Remember your password this time!</div>”;

if(mail($pemail,$subject,$body,$headers))
{
echo “<font>Your password has been send to $pemail</font>”;
}
else
{
echo “<font>Password Not Send.<br><Br>Please Try Again Later!…</font>”;
}

Save as sendpassword.php

Upload on the web and test it

posted under PHP

Email will not be published

Website example

Your Comment:

 

12,958 spam comments
blocked by
Akismet