Forum Moderators: coopster
#### NO PROBLEMS WITH THIS
$admin_mail="2"; // when set to 1 the following works fine, but if 2 the bold code executes
if ($admin_mail == "1") {
if (mail($recipient,$subject,$message,$headers)) {
echo "<p>Thank you! Your testimonial has been successfully submitted.</p>";
include("config.php");
$connection = mysql_connect("$host","$username","$password")or die("cannot connect");
$db = mysql_select_db("$db_name")or die("cannot select DB");
$sql="INSERT INTO $tbl_name(id, value, value1, value2, value3)VALUES('NULL','$value', '$value1', '$value2', '$value3')";
$result = mysql_query($sql);
} else {
echo "<p>Your testimonial could not be sent at this time.</p>";
}
}
}
}
####
When $admin_mail="2"; the following works, but the text in the ELSE statement shows without an error.
####
if ($admin_mail == "2") {
echo "<p>Thank you! Your testimonial has been successfully submitted.</p>";
include("config.php");
$connection = mysql_connect("$host","$username","$password")or die("cannot connect");
$db = mysql_select_db("$db_name")or die("cannot select DB");
$sql="INSERT INTO $tbl_name(id, value, value1, value2, value3)VALUES('NULL','$value', '$value1', '$value2', '$value3')";
$result = mysql_query($sql);
} else {
echo "This is what is appearing when you visit the form, but shouldn't unless there is an error.";
}
####
I am missing something with the code in bold because it submits the info, but whatever is in the "else" statement shows before the form is submitted, and I want to show an error like the code at the top that works. It did this when I removed the mail() statement...so maybe with one less condition it is throwing a "false" automatically. Thank you for any help.