Hi Dave,
Here's a demonstration in principal - but it does need a small code hack.
The hack is this:
(a) in components/com_chronocontact.php add '$validate = array();' around line 14
(b) in the same file look for function showform() and add 'global $validate;' just below it.
(c) do the same for the function uploadandmail() in the same file.
(d) in the file components/com_chronocontact.html.php do the same for function showform()
Now we can use the $validate array to pass information
I created a very simple form with the following html code
<?php
$name_valid = 'none';
if ( $validate['name_error'] ) {
$name_valid = 'block';
}
?>
Name: <input name="name" value="<?php echo $_POST['name']; ?>" type="text"><br />
<span style='display:<?php echo $name_valid; ?>;' >Error in name field.<br /></span>
Email: <input name="email" value="<?php echo $_POST['email']; ?>" type="text"><br />
<input name="submit" value="Submit" type="submit">
and the following code in the 'On Submit code before sending email' field:
<?php
$error = false;
if ( !$_POST['name'] || $_POST['name'] == '' ) {
$validate['name_error'] = true;
$error = true;
}
if ( $error ) {
showform();
}
?>
This form has trivial validation - it just requires something in the 'name' field. If you leave the name field blank but type something in the email field you'll see that this is preserved.
I do agree that this is not an ideal solution but it does demonstrate server side validation with minimal changes to the code base.
Bob<br><br>Post edited by: GreyHead, at: 2007/08/29 21:11