//HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <table width="398" border="0" cellpadding="3" cellspacing="1" > <tr> <td width="38%"><strong>Enter your email : </strong></td> <td width="62%"><form name="form1" method="post" action="send_password_ac.php"> <input name="email_to" type="text" id="mail_to" size="25"> <input type="submit" name="Submit" value="Submit"> </form> </td> </tr> </table> </body> </html> //PHP <?php $host="208.112.101.236"; // Host name $username="infadesign"; // Mysql username $password="Mistainfa1"; // Mysql password $db_name="infadesign"; // Database name //Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); // value sent from form $email_to=$_POST['email_to']; // table name $tbl_name=Family; // retrieve password from table where e-mail = $email_to(mark@phpeasystep.com) $sql="SELECT password FROM $tbl_name WHERE Email='$email_to'"; $result=mysql_query($sql); // if found this e-mail address, row must be 1 row // keep value in variable name "$count" $count=mysql_num_rows($result); // compare if $count =1 row if($count==1){ $rows=mysql_fetch_array($result); // keep password in $your_password $your_password=$rows['password']; //Send email// // send e-mail to ... $to=$email_to; // Your subject $subject="Your password here"; // From $header="from: your name <your email>"; // Your message $messages= "Your password for login to our website
"; $messages.="Your password is $your_password
"; $messages.="Copy the down next time
"; // send email $sentmail = mail($to,$subject,$messages,$header); } // else if $count not equal 1 else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Password Has Been Sent To Your Email Address."; } else { echo "Cannot send password to your e-mail address"; } ?> |