PHP
  Home arrow PHP arrow Building a PHP 5 Form Processor: Coding the Form Generator Module
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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 a PHP 5 Form Processor: Coding the Form Generator Module
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 26
    2006-01-16


    Table of Contents:
  • Building a PHP 5 Form Processor: Coding the Form Generator Module
  • Creating online forms: defining a reusable class for rendering form elements
  • Integrating client-side validation: defining the signature of the “JSGenerator” class
  • Constructing forms programmatically: defining the “formGenerator” class

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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 a PHP 5 Form Processor: Coding the Form Generator Module
    ( Page 1 of 4 )

    Most developers must deal with the job of developing robust data validation for forms on a regular basis. Nobody wants to write the same code over and over, so this article (the first of three in a series) will help you develop an extensible and reusable form validation package. By the end of the article, you will have all the relevant classes that integrate the generator module of the PHP form processor.

    Introduction

    As you’ll probably agree, one of the most common tasks during the development of a web application consists of writing checking code for validating user input, submitted by online forms. From a developer’s point of view, this might be sometimes an annoying activity, because it’s one of the things that you’re likely to do over and over again. Moreover, if you write and release an application which lacks form user data validation routines, sooner or later it will be broken up, due to the constant submission of erroneous data, either because of ignorance or maliciousness.

    Considering that developing robust data validation is something that doesn’t bear discussion, and certainly is one of those jobs that most developers have to face very often, the best way to tackle the problem is either by picking up an existing validation library, or building in a reusable package. If you’re feeling inclined toward the first option, you can start using one of the numerous form checking libraries available on the Web. It’s just a few clicks away.

    However, for those developers wanting to dive into the development of an extensible and reusable form validation package, this article might serve as an introductory process for developing and implementing an object-based form generation-verification solution. Since PHP supports creating classes in a very friendly way, in this first article I’ll walk through a step-by-step format to build some highly generic, customizable PHP 5 form generation classes. This first library of classes will comprise what I call a “generator” module, and allow you to programmatically construct (X)HTML forms, offering basic client-side validation features. Similarly, the second tutorial of this series will focus on developing a “validator” module, which will include a useful server-side validation class.

    The end result of this experience will be a PHP 5 form processor, which can be customized with little difficulty, so it can work for you. Before I start coding the application’s first module, I’d like to state a few requirements: you’ll need to have an intermediate knowledge of object programming in PHP 5, as well as a basic familiarity with some of the PHP built-in data introspection functions.

    With the formalities out of the way, let’s get started.



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT