Conflict Validation Toolkit and Form Toolkit plus more.
I have an email form at enquiries.php under construction.
I set up file upload and validation on file size with Validation toolkit.
All worked well.
I then decided I needed Captcha, so I bought Form Toolkit yesterday.
After applying Captcha and applying Show if (separate problem), I couldn't get the page to display due to a PHP conflict between the Validation Toolkit 2 files and the form toolkit files.
<?php require_once("webassist/form_validations/wavt_scripts_php.php"); ?>
<?php require_once("webassist/form_validations/wavt_validatedform_php.php"); ?>
<?php require_once("WA_ValidationToolkit/WAVT_Scripts_PHP.php"); ?>
<?php require_once("WA_ValidationToolkit/WAVT_ValidatedForm_PHP.php"); ?>
So I deleted the older "WA_ValidationToolkit" scripts and then the page would display.
But the show if behaviour didnt work.
On examination of the code, there was a conflict between the original file size server behaviour, and the show if server behaviour, in that the show if server behaviour setup thought that the code block from the file size server behaviour was the one to use for the show if code, despite my following setup correctly.
e.g, This is the PHP code that now enables "Show If" to work:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$WAFV_Redirect = "enquiries.php";
$_SESSION['WAVT_enquiries_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM(((isset($_FILES["file"]))?$_FILES["file"]["size"]:"") . "",0,5000000,"",",.",true,1);
$WAFV_Errors .= WAValidateLE($_SESSION['captcha_Security_Code_1'] . "",((isset($_POST["Security_Code_1"]))?$_POST["Security_Code_1"]:"") . "",true,2);
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"enquiries");
}
}
?>
The "Show if" application originally installed a second code block similar to this, containing the line: $WAFV_Errors .= WAValidateLE($_SESSION['captcha_Security_Code_1'] . "",((isset($_POST["Security_Code_1"]))?$_POST["Security_Code_1"]:"") . "",true,2);
So I had to lift this line of code, and place it in the first code block, because the "Show If" behaviour (following) expected it to be there, and delete the second code block.
<img id="capt1" src="webassist/captcha/wavt_captchasecurityimages.php?width=200&height=50&field=Security_Code_1&bgcolor=FFFFFF&transparent=1&bgimage=&gridfreq=20&gridcolor=000000&gridorder=behind&noisefreq=20&noisecolor=000000&noiseorder=behind&characters=5&charheight=&font=fonts/MYTYPE.TTF&textcolor=000000" alt="security code" width="200" height="50" /><br />
<input id="Security_Code_1" name="Security_Code_1" type="text" value="" /><br />
<?php
if (ValidatedField('enquiries','enquiries')) {
if ((strpos((",".ValidatedField("enquiries","enquiries").","), "," . "2" . ",") !== false || "2" == "")) {
if (!(false)) {
?>
<span style="color:#F00;">Wrong Code - Try Again</span>
<?php //WAFV_Conditional enquiries.php enquiries(2:)
}
}
}?>
Now all is working fine, basically, except I have another 2 problems now.
If a user incorrectly places the captcha text in the box, the error message appears correctly, but all of the other form input dissapears and the user has to re-input.
If the above occurs, the captcha text is entered correctly, and the user later gets a "File too large" error message, the Captcha error message is also displayed.
I believe it it because the errors are stored in Sessions?
Also:
If a user incorrectly places the captcha text in the box, the error message appears correctly, and all of the other form input dissapears.
If the user leaves the page and later returns, the captcha error message is still there.
I have spent three days of unproductive time on this, due I believe to imperfect communication between the various extensions.
In order for this form to be a professional job, I need the error messages to perform better. Please assist.
At the moment, I feel like dumping webassist completely.