Enhancing Websites with PHP

Processing HTML Forms & Data Validation

Filling out web forms is an integral part of most web users’ surfing routine. You have no doubt filled out a form to do one or more of the following at least once if not on a regular basis:

• Used a search engine
• Registered on a site
• Shopped online
• Took a class online
• Filled out a survey
• Played an online game
• Chatted with someone online
• Paid a bill onlineThe above list, of course is not all inclusive, but if you can identify with any of them and if you consider how many people likely surf the same way you do, you can begin to appreciate the volume of data servers have to process every day. The real power behind PHP is in its ability to do that. It can validate the data submitted, make decisions about it, store it in a file or database for later retrieval or modification, and output the results. Exactly what it does depends entirely on the instructions you give it in your scripts, however at this stage, it is critical to understand that regardless of how well you write your instructions, if your HTML form is flawed, your application will not work.In this unit, you will learn how to design robust HTML forms and write simple scripts to process the data. Specifically, you will learn how to properly set up your form, specify the values of the action and method attributes, and to correctly name form elements. In addition, you will learn how to write simple instructions that retrieve the form data, validate it, and make decisions about it.