PHP
  Home arrow PHP arrow Page 3 - Building An Extensible Form Validator ...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building An Extensible Form Validator Class
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 39
    2002-03-27

    Table of Contents:
  • Building An Extensible Form Validator Class
  • Back To Class
  • The Bare Bones
  • How Things Work
  • Private Eye
  • Running On Empty
  • Floating Like A Butterfly
  • Mail Dot Com
  • Under Construction
  • A Quick Snack
  • Going To The Source
  • Closing Time

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Building An Extensible Form Validator Class - The Bare Bones


    (Page 3 of 12 )

    So that's the theory. Let's now spend a few minutes discussing the rationale behind the FormValidator object I plan to build.

    Stripped down to its bare bones, my FormValidator class consists of two components:

    1. A series of methods that accept the data to be validated as method arguments, test this data to see whether or not it is valid (however "valid" may be defined within the scope of the method), and return an appropriate result code.

    2. A PHP structure (here, an associative array) that holds a list of all the errors encountered during the validation process, and a series of methods to manipulate this structure.

    As you will see, these two basic components make it possible to build a very simple (and yet very useful) FormValidator object, one that exposes a number of generic methods. It's important to note, however, that these methods will have nothing to do with the visual presentation of either the form or the form's result page; rather, they provide a simple API to perform validation of the data entered into the form, and are designed for use by server-side scripts which are more closely connected to the presentation layer.

    More PHP Articles
    More By icarus, (c) Melonfire


     

       

    PHP ARTICLES

    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway