26231PHP With HTML Formshttp://www.oreillynet.com/pub/a/php/2000/12/01/php_phanatics.htmlIn the last exciting episode of the PHP Phanatics, we explored the inner workings of PHP's unique $GLOBALS array. Several sharp-eyed readers pointed out a bug in the script dumping the contents of the $GLOBALS array. If an array element was itself an array, the display listed that fact rather than the contents of the component array. The displayed line looked like:PHP > Tips and Tutorials > Form ProcessingOct 15, 2006
Mosaic, with its multimedia capability, added entertainment value to what had previously been a bland character-based medium. Forms created the capability for dynamic Web sites tailored to user requests. Without either of these two developments, we would all probably be watching TV right now.
In the last article, the Phanatic was leading an expedition into a largely uncharted area. The conceptual project was a generalized form handler. The task's starting point was Matt Wright's famous "formmail" and included adding many more bells and whistles. While putting together the last tome, time and space were closing in on us, and in an effort not to strain the Phanatic's rapidly aging brain, we pulled into shore for a rest. Let's review the project's design goals before setting out to sea again.
The validation of data that has been entered in a form is necessary in most cases. Why is important? For example, what good is holding a contest or sweepstakes if you can't notify the winner, because he or she entered an invalid telephone number or an incorrect address. What good is having a mailing list if the e-mail addresses on it aren't verified, and your mailing list just bounces back to you without reaching the subscribers and target audience.Validating form entries saves you time and more importantly, it can save you money. And since somebody embossed the slogan "Time is money!", this should be very important for your web site!Well when should we validate? There are two types of validation; client side and server side.For reference, client side means that you are depending on what browser the user is currently using. On the client side, validation is performed using JavaScript. And that can be very tricky, because some users turn off JavaScript support in their browsers before they even come to your site. If you encounter of one those users, client side validation won't help you much if you try to verify data from a form because your JavaScript code will not be executed or interpreted by the browser, means you are back to square 1. Remember, the winner of your competition entered a wrong address.This is where server side validation comes in handy. It will always work, no matter what. Of course assuming that you have access to the technology on your server. Server side validation can be done with Perl, PHP, ASP, ColdFusion, JSP and almost any other scripting language. For this tutorial, I'll use PHP. A quite popular and easy to master server side scripting language.
Checkboxes in web forms are useful because they allow the person filling out the form to choose from a wide range of possible choices. Specifically, it allows the user to choose some, all or none of the elements. Although checkboxes are excellent form elements for certain tasks, there is often confusion about how to store checkbox data correctly. This article will demonstrate how to store checkbox data in a database, in a manner that follows good database design principles.
One recent evening the Phanatic and a few friends were splitting an extra large pizza and a few six packs of Jolt. The Phanatic was pontificating as usual about good program design and problem generalization. One of the PHP apostles, probably egged on by a Jolt buzz, challenged the Phanatic to "practice what you preach" and design a program that solved a class of problems rather a single task. Another of the assembled brethren suggested the Phanatic use the NuSphere suite he had been extolling recently. The gauntlet was thrown down.
Joining mailing list will entitle you
to receive occasional emails informing you of news and
updates to the site and any special offers that may be
of interest to you.