PHP Classes

File: validation_demo.php

Recommend this page to a friend!
  Classes of Alankar   PHP Validaton class   validation_demo.php   Download  
File: validation_demo.php
Role: Example script
Content type: text/plain
Description: Demo for PHP validation class
Class: PHP Validaton class
Validate submitted form values according to rules
Author: By
Last change:
Date: 8 years ago
Size: 871 bytes


Class file image Download
<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>

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>";
} else {
// all applied validations are passed. You can deal with your submitted information now.
echo "<pre>";