PHP Classes

Form Data Validator: Validate submitted form input values

Recommend this page to a friend!
  Info   View files Example   Demos   Screenshots Screenshots   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 535 All time: 5,623 This week: 455Up
Version License PHP version Categories
form-data-validator 1.0GNU General Publi...5.2HTTP, PHP 5, Validation


This class can validate submitted form input values.

It can take an array with accepted form inputs and required inputs and validates a given $_POST or $_GET array with submitted form values.

The class returns an array with validated form values and validation errors.

Picture of Nemeth Zoltan
  Performance   Level  
Name: Nemeth Zoltan is available for providing paid consulting. Contact Nemeth Zoltan .
Classes: 9 packages by
Country: Hungary Hungary
Age: 46
All time rank: 157113 in Hungary Hungary
Week rank: 307 Up4 in Hungary Hungary Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x


<h3>Simple validator class for form data</h3>
 * Teszt for FormDataValidator class
if (isset($_POST) && count($_POST) > 0) {
"<pre>Validation start.<hr>POST data<br>---<br>";
$accepted = array('name', 'nick', 'email', 'message');
$required = array('name', 'nick', 'message');
$validator = new FormDataValidator($_POST, $accepted, $required);
$resp = $validator->validate();
"<br>After validation<br>";

<p>Please fill and put the following form:</p>
  <form method="post" action="index.php">
    Name*: <input type="text" name="name" value="<?php print trim($_POST['name']); ?>" /><br>
    Nick: <input type="text" name="nick" value="<?php print trim($_POST['nick']); ?>" /><br>
    E-mail*: <input type="text" name="email" value="<?php print trim($_POST['email']); ?>" /><br>
    Message*: <input type="text" name="message" value="<?php print trim($_POST['message']); ?>" /><br>
    Not accepted: <input type="text" name="sample" value="<?php print trim($_POST['sample']); ?>" /><br>
    <input type="submit" value="Send"/>

  • sample_output
  Files folder image Files  
File Role Description
Plain text file formDataValidator.class.php Class The main class
Accessible without login Plain text file index.php Example Test file for the class
Accessible without login Plain text file output.txt Output Sample output from index.php

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:5,623
This week:455Up
User Comments (2)
Provides a good validation class skeleton.
9 years ago (J Diamond)
This is a good and useful class :-)
9 years ago (Josť Filipe Lopes Santos)