close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Server Side validtion and captcha

Thread began 5/27/2014 6:37 am by Steve | Last modified 5/27/2014 10:04 am by Steve | 2606 views | 7 replies

Steve

Server Side validtion and captcha

Hello,
On a form with Server Side Validation I have also added Captcha...

The problem is that while it works with two independent validations, the form elements do not retain their Post values on refresh of checking the captcha.

I can see that two separate server validations are the problem.

What's the quick and simple way to merge the two and have both work?

Here are the two sections of code:

<?php 
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$WAFV_Redirect = "index.php";
$_SESSION['WAVT_indexX_276_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateLE($_SESSION['captcha_Security_Code_1'] . "",((isset($_POST["Security_Code_1"]))?$_POST["Security_Code_1"]:"") . "",true,35);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"indexX_276");
}
}
?>
<?php
if (($_SERVER["REQUEST_METHOD"] == "POST") && (isset($_SERVER["HTTP_REFERER"]) && strpos(urldecode($_SERVER["HTTP_REFERER"]), urldecode($_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"])) > 0) && isset($_POST)) {
$WAFV_Redirect = "";
$_SESSION['WAVT_index_524_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateRQ(((isset($_POST["sel-week"]))?$_POST["sel-week"]:"") . "",false,1);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Name"]))?$_POST["Name"]:"") . "",false,2);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["LastName"]))?$_POST["LastName"]:"") . "",false,3);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Age"]))?$_POST["Age"]:"") . "",false,4);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Height"]))?$_POST["Height"]:"") . "",false,5);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["HeightInch"]))?$_POST["HeightInch"]:"") . "",false,6);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Shirt_Size"]))?$_POST["Shirt_Size"]:"") . "",false,1);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Name2"]))?$_POST["Name2"]:"") . "",false,7);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["LastName2"]))?$_POST["LastName2"]:"") . "",false,8);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["ParentGuardian"]))?$_POST["ParentGuardian"]:"") . "",false,9);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Email"]))?$_POST["Email"]:"") . "",false,10);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Address"]))?$_POST["Address"]:"") . "",false,11);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["City"]))?$_POST["City"]:"") . "",false,12);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["State"]))?$_POST["State"]:"") . "",false,13);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Zip"]))?$_POST["Zip"]:"") . "",false,14);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["areaMedCon"]))?$_POST["areaMedCon"]:"") . "",false,15);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Medications"]))?$_POST["Medications"]:"") . "",false,16);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Interval"]))?$_POST["Interval"]:"") . "",false,17);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["areaAllergies"]))?$_POST["areaAllergies"]:"") . "",false,18);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact1_Name"]))?$_POST["Contact1_Name"]:"") . "",false,19);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact1_Relationship"]))?$_POST["Contact1_Relationship"]:"") . "",false,20);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact1_Home_Phone"]))?$_POST["Contact1_Home_Phone"]:"") . "",false,21);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact1_Cell_Phone"]))?$_POST["Contact1_Cell_Phone"]:"") . "",false,22);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact1_Address"]))?$_POST["Contact1_Address"]:"") . "",false,23);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact1_City"]))?$_POST["Contact1_City"]:"") . "",false,24);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact1_State"]))?$_POST["Contact1_State"]:"") . "",false,25);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact1_Zip"]))?$_POST["Contact1_Zip"]:"") . "",false,26);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_Name"]))?$_POST["Contact2_Name"]:"") . "",false,27);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_Relationship"]))?$_POST["Contact2_Relationship"]:"") . "",false,28);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_Home_Phone"]))?$_POST["Contact2_Home_Phone"]:"") . "",false,29);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_Cell_Phone"]))?$_POST["Contact2_Cell_Phone"]:"") . "",false,30);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_Address"]))?$_POST["Contact2_Address"]:"") . "",false,31);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_City"]))?$_POST["Contact2_City"]:"") . "",false,32);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_State"]))?$_POST["Contact2_State"]:"") . "",false,33);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_Zip"]))?$_POST["Contact2_Zip"]:"") . "",false,34);



if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"index_524");
}
}
?>





In page example:

<input name="Contact2_Zip" type="text"   id="Contact2_Zip" value="<?php echo(ValidatedField("index_524","Contact2_Zip")) ?>" size="12">

<?php
if (ValidatedField('index_524','index_524')) {
if ((strpos((",".ValidatedField("index_524","index_524").","), "," . "" . ",") !== false || "" == "")) {
if (!(false)) {
?> <div style="background-color: rgba(255,229,0,1.00); border-radius: 6px; border: 1px solid rgba(255,174,0,1.00);padding:6px;">All fields are REQUIRED except signing up to receive email promotions. Please review your document and complete any fields left unsigned.</div>
<?php //WAFV_Conditional index.php index_524( :)
}
}
}?>


<img id="capt1" src="../webassist/captcha/wavt_captchasecurityimages.php?width=200&height=50&field=Security_Code_1&bgcolor=FFFFFF&transparent=0&bgimage=&gridfreq=20&gridcolor=000000&gridorder=behind&noisefreq=20&noisecolor=000000&noiseorder=behind&characters=5&charheight=&font=fonts/MOM_T___.TTF&textcolor=000000" alt="security code" width="200" height="50" /><img src="../webassist/captcha/images/refresh.png" height="18" onClick="document.getElementById('capt1').src+='&ref=1'">


<?php
if (ValidatedField('indexX_276','indexX_276')) {
if ((strpos((",".ValidatedField("indexX_276","indexX_276").","), "," . "35" . ",") !== false || "35" == "")) {
if (!(false)) {
?>
<div style="background-color: rgba(255,229,0,1.00); border-radius: 6px; border: 1px solid rgba(255,174,0,1.00); padding: 6px; width: 300px;">Security values not entered as shown. Please enter again and submit.</div>
<?php //WAFV_Conditional indexX.php indexX_276(35:)
}
}
}?>



Is the solution to move the single captcha validation to the full page validations such as :

...
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_City"]))?$_POST["Contact2_City"]:"") . "",false,32);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_State"]))?$_POST["Contact2_State"]:"") . "",false,33);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_Zip"]))?$_POST["Contact2_Zip"]:"") . "",false,34);
$WAFV_Errors .= WAValidateLE($_SESSION['captcha_Security_Code_1'] . "",((isset($_POST["Security_Code_1"]))?$_POST["Security_Code_1"]:"") . "",true,35);


Or is it correct to add a new validation such as :

...
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_City"]))?$_POST["Contact2_City"]:"") . "",false,32);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_State"]))?$_POST["Contact2_State"]:"") . "",false,33);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Contact2_Zip"]))?$_POST["Contact2_Zip"]:"") . "",false,34);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["Security_Code_1"]))?$_POST["Security_Code_1"]:"") . "",false,36);



What is "WAValidateLE" in comparison to "WAValidateRQ"?

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...