Hi all,
I am working on a send password script and have the basics laid out below, the problem I am having is that I get an undefined variable on $sentmail, which is bold in the code below. Any ideas?
$email_to=$_POST['email_to'];
//$stremail_to = isset($_POST['email_to']) ? $_POST['email_to'] : "";
// table name
//$tbl_name=users;
// retrieve password from table where e-mail = $email_to(mark@phpeasystep.com)
$sql="SELECT password FROM users WHERE email_address='$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 e-mail to ...
$to=$email_address;
// Your subject
$subject="Head2ToeWeddings Login Details";
// From
$header="from: Head2ToeWeddings <your email>";
// Your message
$messages= "Your password for login to our website \r\n";
$messages.="Your password is $password \r\n";
$messages.="While emails are generally regarded as safe, we advise you to login and update your password in order to ensure that no one else can gain access to your personal details.\r\n";
// 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([B]$sentmail[/B]){
echo "Your Password Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send password to your e-mail address";
}
?>
By the way, email_to is a field from another page where the user fills in their email address.
Thanks,
G