$host="localhost"; // Host name
$username="mylodgeh_ksala"; // mysql username
$password="OrientOfLouisiana@1"; // mysql password
$db_name="mylodgeh_ksala"; // Database name
//Connect to server and select databse.
($GLOBALS["___mysqli_ston"] = mysqli_connect("$host", "$username", "$password"))or die("cannot connect to server");
mysqli_select_db($GLOBALS["___mysqli_ston"], $db_name)or die("cannot select DB");
// value sent from form
$email_to=$_POST['email_to'];
// table name
$tbl_name=members;
// retrieve password from table where e-mail = $email_to(mark@phpeasystep.com)
//BOTH sql statements below work
$sql="SELECT Email, pwd FROM users WHERE Email = '$email_to'";
//$sql="SELECT Email, pwd FROM `users` WHERE Email = '".$_POST['email_to']."'";
$result=mysqli_query($GLOBALS["___mysqli_ston"], $sql);
// if found this e-mail address, row must be 1 row
// keep value in variable name "$count"
$count=mysqli_num_rows($result);
// compare if $count =1 row
if($count==1){
$rows=mysqli_fetch_array($result);
// keep password in $your_password
$your_password=$rows['pwd'];
// ---------------- SEND MAIL FORM ----------------
// send e-mail to ...
$to=$email_to;
// Your subject
$subject="USC-DC LodgeHelper Membership Management System Lost Password";
// From
$headers .= 'From: LodgeHelper HelpDesk ' . "\r\n";
$headers .= 'Bcc: wastechnologies@gmail.com' . "\r\n";
'Reply-To: info@lodgehelper.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
// Your message
$messages= "Your forgotten password to the USC-DC Membership Management System. \r\n";
$messages.="Your password is $your_password \r\n";
$messages.="Please call us at 714-805-9OTS (9687) if you need further assistance. \r\n";
// send email
$sentmail = mail($to,$subject,$messages,$headers);
mail($to,$subject,$messages,$headers);
}
// else if $count not equal 1
else {
echo "
";
}
// if your email succesfully sent
if($sentmail){
echo "
An email has been sent to you. If you need further assistance, please call 714.805.9OTS (9687)