My feedback form works if entry fields contain valid data, and displays errors if the fields don't, but the final if test never gets evaluated to true.
Why is the test failing ? How can I make it work ?
$errmessage = "";
$errflag = 0;
/ I revised the order in this test after reading Debugging 101, and I understand why it's much safer. The error message gets displayed every time the Name is 3 chars or less /
if (4 > strlen(trim($name)))
{
$errmessage ="<strong>Please enter your name </strong><br />";
$errflag = 1;
echo "error Flag:".strlen(trim($name)).$errmessage.$errflag."<br />";
}
/ I haven't revised the order, as the error message gets displayed every time the Enquiry is 4 chars or less /
if (strlen(trim($enquiry))< 5)
{
$errmessage =$errmessage."<strong>Please enter your enquiry </strong><br />";
$errflag = 1;
echo "error Flag:".strlen(trim($enquiry)).$errmessage.$errflag."<br />";
}
/ When errors are displayed, the echo confirms that $errflag has the value 1, but the error message below never gets displayed. I can't see why - I'm using the comparison operator '=='. From debugging 101 I've changed the order of the comparison, however it didn't make any difference./
if (1==$errflag)
{ $errmessage = $errmessage."Please press the back button ";
$errmessage = $errmessage."and correct your mistake(s)";
}
else {
mail ($recipient, $subject, $content, $headers);