<form name="frmTest" id="frmTest" action="" method="POST">
<input type="text" name="first_name" id="first_name" value = "" />
<button name="submit" value="Submit" type="submit" >Submit</button>
</form>
<?php
require_once 'validation.php';
$array = array('method' => 'POST',
'rules' => array('first_name' => array('required' => true,
'url' => true)
),
'messages' => array('first_name' => array('required' => 'Please enter first name')
)
);
$response = Validation::_initialize($array, $_POST);
// if some error messages are present.
if (!$response['valid']) {
// it will give you the array with error messages.
echo "<pre>";
print_r($response);
} else {
// all applied validations are passed. You can deal with your submitted information now.
echo "<pre>";
print_r($_POST);
}
?>
|