error message Notice: Undefined variable: sentmail in /home/stud/1/0472547/public_html/send_password.php on line 59

The code works but when wrong email is entered and it cant find it in the database it comes up with that error its all right but for some reason its saying undefined variable

// ---------------- SEND MAIL FORM ----------------

// send e-mail to ...

// Your subject
$subject="Your password here";

// From
$header="from: your name <your email>";

// Your message
$messages= "Your password for login to Fast Learner \r\n";
$messages.="Your password is $your_password \r\n";
$messages.="more message... \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";

//=============error message is here cant figure it out where it says if ($sentmail){
// if your email succesfully sent
echo "Your Password Has Been Sent To Your Email Address.";
else {
echo "Cannot send password to your e-mail address";


10 Years
Discussion Span
Last Post by Suomedia

Somewhere up the top put:

$sentmail = NULL;

Matti Ressler

didnt work made more errors


It did not make more errors at all (not possible), in fact its not need. I just ran what you posted (with a minor addition to make it complete) and received an email as expected.

The problem is elsewhere in your code. The actual error message would help.

Matti Ressler


Hello cant see what u mean it sends email when the email is found from the database but it when there isnt a password that matches it comes up with the right message but says undefined variable

Not found your email in our database
Notice: Undefined variable: sentmail in /home/stud/1/242422/public_html/send_password.php on line 100
Cannot send password to your e-mail address

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.