I am using server side validation on a form I've developed and it doesn't seem to be working for me as expected. The tooltip for the "Server Side Validation Code" says:
That is exactly the behavior I want but haven't been successful, so far. In searching the forum, I found that using showform($post) will redisplay the form and it does, but the form submission processing continues on to my "after sending email" code on the "Form Code" tab. So, what I get is the form, the error message, and my response page.
I am using Joomla! 1.5.10 and Chronoforms V3.1 RC4.0. Here is my "server-side" validation code:
I know I'm missing something here... just haven't been able to find it.
Thanks.
Rosie
Add here some PHP code with tags to get executed on form submission, in case this code returned any data, the form submission will be halted, the form will be reshown, and your returned data will be displayed in a message above the form.
That is exactly the behavior I want but haven't been successful, so far. In searching the forum, I found that using showform($post) will redisplay the form and it does, but the form submission processing continues on to my "after sending email" code on the "Form Code" tab. So, what I get is the form, the error message, and my response page.
I am using Joomla! 1.5.10 and Chronoforms V3.1 RC4.0. Here is my "server-side" validation code:
<?php
if ($_POST['email'] != "") {
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors .= "$email is <strong>NOT</strong> a valid email address.<br/><br/>";
}
} else {
$errors .= 'Please enter your email address.<br/>';
}
if ($_POST['first_name'] != "") {
$_POST['first_name'] = filter_var($_POST['first_name'], FILTER_SANITIZE_STRING);
if ($_POST['first_name'] == "") {
$errors .= 'Please enter a valid first name.<br/><br/>';
}
} else {
$errors .= 'Please enter your first name.<br/>';
}
if ($_POST['last_name'] != "") {
$_POST['last_name'] = filter_var($_POST['last_name'], FILTER_SANITIZE_STRING);
if ($_POST['last_name'] == "") {
$errors .= 'Please enter a valid last name.<br/>';
}
} else {
$errors .= 'Please enter a your last name.<br/>';
}
if ($errors) {
echo '<div style="color: red">' . $errors . '<br/></div>';
showform($post);
}
?>
I know I'm missing something here... just haven't been able to find it.
Thanks.
Rosie