Home arrow PHP arrow Building a PHP 5 Form Processor: Coding the Form Generator Module

Building a PHP 5 Form Processor: Coding the Form Generator Module

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.

TABLE OF CONTENTS:
  1. Building a PHP 5 Form Processor: Coding the Form Generator Module
  2. Creating online forms: defining a reusable class for rendering form elements
  3. Integrating client-side validation: defining the signature of the “JSGenerator” class
  4. Constructing forms programmatically: defining the “formGenerator” class
By: Alejandro Gervasio
Rating: starstarstarstarstar / 30
January 16, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: