close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

How can I incorporate the show if server behavior in an existing PHP script?

Thread began 3/30/2016 2:36 am by markhaynes75235 | Last modified 4/05/2016 2:47 pm by markhaynes75235 | 309 views | 12 replies

markhaynes75235

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!

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...