<h3>Simple validator class for form data</h3>
<?php
/*
* Teszt for FormDataValidator class
*/
if (isset($_POST) && count($_POST) > 0) {
echo "<pre>Validation start.<hr>POST data<br>---<br>";
var_export($_POST);
require_once 'formDataValidator.class.php';
$accepted = array('name', 'nick', 'email', 'message');
$required = array('name', 'nick', 'message');
$validator = new FormDataValidator($_POST, $accepted, $required);
$resp = $validator->validate();
echo "<br>After validation<br>";
var_export($resp);
echo "</pre>";
}
?>
<p>Please fill and put the following form:</p>
<form method="post" action="index.php">
Name*: <input type="text" name="name" value="<?php print trim($_POST['name']); ?>" /><br>
Nick: <input type="text" name="nick" value="<?php print trim($_POST['nick']); ?>" /><br>
E-mail*: <input type="text" name="email" value="<?php print trim($_POST['email']); ?>" /><br>
Message*: <input type="text" name="message" value="<?php print trim($_POST['message']); ?>" /><br>
Not accepted: <input type="text" name="sample" value="<?php print trim($_POST['sample']); ?>" /><br>
<input type="submit" value="Send"/>
</form>
|