How can I incorporate the show if server behavior in an existing PHP script?
I have a contact form on my site that uses a custom php script along with a jquery script. It has been working fine for some time now, but the form is not as secure as I want it to be, so I've added a Captcha field with the appropriate Like Entry server validation. The jquery script takes each form value and stores it in a variable which is then passed into the processing page. I've assigned the Captcha form element to the variable named "verify" so that now the validation Server Behavior looks like this:
<?php
if ((((isset($_POST["verify"]))?$_POST["verify"]:"") != "")) {
$WAFV_Redirect = "";
$_SESSION['WAVT_contact_413_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateLE($_SESSION['captcha_Security_Code_1'] . "",$_SESSION['captcha_Security_Code_1'] . "",true,1);
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"contact_413");
}
}
?>
Further down in the PHP code on the processing page, a variable is set as follows:
$verify = $_POST['verify'];
and then in the series of validation conditions, I've set the following:
} else if (trim($verify) == '') {
echo '<div class="error_message">Attention! Please enter the CAPTCHA code.</div>';
exit();
} else if (ValidatedField('contact_413','contact_413')) {
if((strpos((",".ValidatedField("contact_413","contact_413").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
echo '<div class="error_message">Attention! The CAPTCHA code you entered is incorrect.</div>';
//WAFV_Conditional ../contact.php contact_413(1:)
exit();
}
}
}
When I test the form and leave the Captcha field blank, the first condition shown above triggers the <div class="error_message">Attention! Please enter the CAPTCHA code.</div>, but when I enter an incorrect Captcha code, the second error message does not show up, instead, the form is submitted with no alert.
I've attached a sample page with the menu include file, the jquery file and the processor page as attachments. the pagetemplate2col.php and the contact.php are in the site root. The jquery.jigowatt.js is under the js folder in the site root and the menu01f.php is found in the includes folder under the site root.
Please let me know if you can find why the show if is not working for the incorrectly entered values.
Thanks!