Okay, I'm at wits end. After laboring for hours over my first PHP script designed to do some form validation, the script still allows the form to be sent even if the email validation fields do not match. The code in question is here:
if (strlen($proposerEmail) > 0) {
}
else {
$errorMessage .= '<p class="alert">!! You forgot to enter your email address.</p>';
}
if (strlen($proposerEmailValidate) > 0) {
}
else {
$errorMessage .= '<p class="alert">!! Please validate that your email address is correct by retyping.</p>';
}
if ((strlen($proposerEmail) > 0) && (strlen($proposerEmailValidate) > 0) && $proposerEmail != $proposerEmailValidate)
{
$errorMessage .= '<p class="alert">!! We asked you to type your email address twice to help make sure it is correct, and the two don\'t seem to match. Would you mind trying again?</p>';
}
... the script then goes on to do a range of validations on several other fields before emailing the form contents ...
if ($proposerName && $proposerInstitution && $proposerEmail && $proposerEmailValidate && $proposerTelephone && $programTitle && $programCategory && $programFormat && $programDescription) {
$to = "[email address], [email address]/email]"; [the rest snipped--the email function, by the way, is working fine]
SO, as long as there are other errors in the form, e.g. a field is left out, the above works properly, but just as soon as all the required fields are filled in, the script is still allowing the form to be sent though the values behind "$proposerEmail" and "$proposerEmailValidate" are not equal.
I'm sure I've made a egregious error, so please be kind.
If anyone needs to see the full file, please be in touch at samuel.duncan@sbcglobal.net.
Thanks buckets.