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 Shibly  >  Data validation class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example file
Class: Data validation class
Perform several types of validation of text values
Author: By
Last change:
Date: 2 years ago
Size: 1,203 bytes
 

Contents

Class file image Download
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<?php
include_once 'Validator.php';



// check if the number is between 10,30

if (!Validator::Number(55020)) {
    echo 
"The number is not between 20 and 50";
}

else {
    echo 
"Yes, the number is between 20 and 50";
}

echo 
"<br/>";
// email validation

if (!Validator::Email("shibly.phy@gmail.com")) {
    echo 
"Invalid email address";
}

else
{
    echo 
"Email is valid ";
}


echo 
"<br/>";
// Email address validation with exception

if (!Validator::Email("Shibly.phy@test.com", array("test.com"))) {
    echo 
"test.com is not allowed";
}

echo 
"<br/>";

if (!
Validator::Alpha('asd123')) {
    echo 
"this is not a alpha numeric string";
}

else
{
    echo 
"This is a alpha numeric string";
}


echo 
"<br/>";

if (!
Validator::Number("123")) {
    echo 
"Not a number";

}

else

{
    echo 
"Is a number";
}

echo 
"<br/>";

if (!
Validator::Ip("192.164.1.3")) {
    echo 
"This is not a valid IP address";
}

else
{
    echo 
"This is a valid Ip Address";
}
?>


</body>
</html>