PHP Classes

File: Example.php

Recommend this page to a friend!
  Classes of Richard Hayes   Validit   Example.php   Download  
File: Example.php
Role: Example script
Content type: text/plain
Description: Example usage
Class: Validit
Validate user submitted data
Author: By
Last change: TYPO
Date: 21 years ago
Size: 1,703 bytes
 

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', 30, 2), 'name contains illegal characters', '[:space:]');

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

// Check for integer and length
$v -> numericCheck($v -> lengthCheck($_GET['num'], 'number length error', 25, 2), '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', 20, 5), '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', 20, 5), '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();

?>