PHP Classes

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of t withers  >  Model Validation  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example using Validation Class
Class: Model Validation
Validate form values according to many rules
Author: By
Last change:
Date: 3 years ago
Size: 1,932 bytes


Class file image Download
'label'=>'Your text',
'label'=>'The password',
$valid=Validation::set($validate,true);//setting to true will break after a single error. false will put all errors into an array.

<!-- form method can be post or get, php uses the $_REQUEST variable to access the data -->
<?php if(!$valid){
implode(" ",Validation::getErrors ());
}else if(
$valid && $_SERVER['REQUEST_METHOD']=='POST'){
'Looks good!<br/>';

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Text:<textarea name="text"><?php echo isset($_POST['text'])?$_POST['text']:'';?></textarea><br/>
Name:<input type="text" name="contact[name]" value="<?php echo isset($_POST['contact']['name'])?$_POST['contact']['name']:'';?>"/><br/>
Email:<input type="text" name="contact[email]" value="<?php echo isset($_POST['contact']['email'])?$_POST['contact']['email']:'';?>" /><br/>
Password:<input type="password" name="contact[password]" /><br/>
Repeat:<input type="password" name="repeat" /><br/>
Anything but 1:<input type="text" name="anythingbut" value="<?php echo isset($_POST['anythingbut'])?$_POST['anythingbut']:1;?>"/><br/>
<input type="submit"/>