PHP Classes

File: classvalidationexample.php

Recommend this page to a friend!
  Classes of Chike Jibunoh   Rules Validation Class   classvalidationexample.php   Download  
File: classvalidationexample.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Rules Validation Class
Validate request values according to common rules
Author: By
Last change:
Date: 6 years ago
Size: 733 bytes
 

Contents

Class file image Download
<?php
//This is just an example of the usage, not really a working application
$rules = array(
'email' => 'email|required',
'username' => 'name_user|required',
'password' => 'required',
'firstname' => 'name|required',
'lastname' => 'name|required'
);

$validation = new Validation();

if(
$validation->validate($_POST, $rules) == TRUE) {
$email = trim($_POST['email']);
$username = trim($_POST['username']);
$firstname = trim($_POST['firstname']);
$lastname = trim($_POST['lastname']);
$password = hash('sha1', trim($_POST['password']));
$cf_password = hash('sha1',trim($_POST['cf_password']));

}
foreach (
$validation->errors as $error) {
        echo
"<div class = 'alert alert-danger'>" . $error . "</div>";

    }