verifyRules('http://samuelsjoberg.com/files/vform.php',
'/files/vform.php')) {
echo 'Checking rules: OK
';
} else {
die('Checking rules: Corrupted or bypassed! Aborting...');
}
//Validate the form.
if (!$vform->isValid()) {
$errorMessage = $vform->getErrorList(true, 'post_');
$errorClass = 'display';
//Post data needs to be stripped if displayed again
foreach ($_POST as $key => $value) {
if (is_string($value))
$_POST[$key] = stripslashes($value);
}
} else {
die('Validation status: OK');
}
}
?>
This is a demostration of vForm which is described in this entry: Form validation on client and server.
The validation is performed both on the client with Javascript and on the server with PHP. Try disable javascript to see how the server-script kicks in. View the source.