Login   Register  
PHP Classes
elePHPant
Icontem

File: Example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Richard Hayes  >  Validit  >  Example.php  
File: Example.php
Role: Example script
Content type: text/plain
Description: Example usage
Class: Validit
Validate user submitted data
 

Contents

Class file image Download
<?php 
//============================ 
//        Example              
//============================ 

include_once('Validit.php');

$v = new Validit();

// Check for alpha strings and length. This time we want to allow space (\t\r\n) so take 
// note of the third parameter passed to alphaCheck(). This is optional and if left out will 
// prevent strings from containing space.
$v -> alphaCheck($v -> lengthCheck($_GET['name'], 'name length problem'302), 'name contains illegal characters''[:space:]');

// Check for validate email address format and length
$v -> emailCheck($v -> lengthCheck($_GET['email'], 'email length error'807), 'invalid email address');

// Check for integer and length
$v -> numericCheck($v -> lengthCheck($_GET['num'], 'number length error'252), 'not an integer');

// Check for alpha numeric strings and length. This time we want to allow space (\t\r\n) so take 
// note of the third parameter passed to alphaNumericCheck().
$v -> alphaNumericCheck($v -> lengthCheck($_GET['address'], 'address length problem'205), 'address contains illegal characters''[:space:]');

// Check for alpha numeric strings and length. Again take note of the third parameter passed to 
// alphaNumericCheck() this time we want to allow the '_' character
$v -> alphaNumericCheck($v -> lengthCheck($_GET['pass'], 'password length problem'205), 'password contains illegal characters''_');

// Check strings
$v -> compareCheck($_GET['pass'], $_GET['pass2'], 'passwords don\'t match');



// Output errors (if any)
foreach($v -> getErrors() as $output
{
    echo (
$output.'<br>'); 
}

// Reset error list
$v -> resetErrorList(); 

?>