<form action="" method="post">
<input type="text" name="email">
<input type="text" name="website">
<input type="text" name="dob">
<input type="text" name="gender">
<input type="submit" name="submit" value="Submit">
</form>
<?php
require_once "validator.php";
$rules=[
'email'=>'required&email',
'website'=>'url',
'dob'=>'required&numeric&min:2',
'gender'=>'required&in:male,female'
];
$msg=[
'website'=>[
'url'=>'Sorry this not a valid url'
]
];
$valid=Validator::validate($_POST, $rules);
if($valid->hasErrors()){
foreach ($valid->errorsAll() as $err) {
echo '<li>'.$err.'</li>';
}
}
|