PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Sergey   ValidatorClass   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: ValidatorClass
Validation of data submitted via Web forms
Author: By
Last change:
Date: 19 years ago
Size: 830 bytes
 

Contents

Class file image Download
<?
$oValidator
= &new Validator();

$oValidator->mandatory = array(array("value"=>'', "msg"=>"Username"),
                               array(
"value"=>'u_email', "msg"=>"Email address"));

$oValidator->validation = array(array("value"=>"u_email", "func"=>"isEmail", "field"=>"Email address"),
                                array(
"value"=>"u_emai?l.", "func"=>"checkNotAllowChars", "field"=>"Email address", "pattern"=>"/\?/"));

$oValidator->equal = array(array("value1"=>"u_login2", "value2"=>"u_login", "field1"=>"Username", "field2"=>"Username"));

$oValidator->length = array(array("value"=>"u_login", "length_from"=>0, "length_to"=>2, "field"=>"Username", "coincide"=>false));

$out_error = $oValidator->validate();
if (
count($out_error))
{
    foreach(
$out_error as $k=>$v)
        echo
'<font color="red">'.$v."</font><br>";
}

unset (
$oValidator);
?>