PHP Classes

File: validation.php

Recommend this page to a friend!
  Classes of Kevin Burke   Validator.php   validation.php   Download  
File: validation.php
Role: Example script
Content type: text/plain
Description: validation test
Class: Validator.php
Form Validation class
Author: By
Last change:
Date: 20 years ago
Size: 758 bytes
 

Contents

Class file image Download
<?
require_once("Validator.php");

$validator = new Validator($_REQUEST);
$validator->filledIn("fname");
$validator->length("lname", "<", 15);
$validator->email("email");
$validator->compare("pass1", "pass2");
$validator->lengthBetween("color", 3, 15);
$validator->punctuation($sentence);
$validator->value("age", ">", 18);
$validator->valueBetween("number", 11, 16, true);
$validator->alpha("car");
$validator->alphaNumeric("monitor");
$validator->date("date", "mm/dd/yyyy");

$errors = $validator->getErrors();
$id = $validator->getId();
echo
"Validator Id: $id<br><br>";
foreach(
$errors as $key => $value) {
    if(
strstr($key, "|")) {
       
$key = str_replace("|", " and ", $key);
    }
    echo
"<b>Error $value:</b> on field $key<br>";
}
?>