Introduction to Better Forms

   

This chapter covers forms. Forms are the most fundamental method of interaction for your users. Users must use a form to enter information into a site. Think about it, every bulletin board, shopping cart, feedback form, and poll is a type of form. Without forms, the Web is nothing more than a publishing medium for those who can FTP Web pages up to a server.

Since forms are the basis for much of the user interaction on your site, it behooves you to make it easier for users to enter information. How many times have you filled in a long form only to have it tell you that you filled something out wrong and to click "Back" to fix it? Upon clicking the "Back" button you find the entire form empty, forcing you to fill in all of the information again! Or how about forms that tell you that you filled in something incorrectly, but upon closer inspection you cannot tell what is wrong, and the script does not provide any more clues. Wouldn't it be better if you didn't have to enter all of the information again, and the fields that you filled out incorrectly were highlighted some way so that you could easily make corrections?

You can check data before the form is submitted by using JavaScript, but not all browsers treat JavaScript the same way, so you might run into compatibility problems with some browsers. With PHP, you can be sure to send only pure HTML to the browser, reducing cross-browser compatibility errors. Checking for errors using PHP instead of JavaScript does increase the load on the server slightly, depending on the complexity of your code.


   
Top


Advanced PHP for Web Professionals
Advanced PHP for Web Professionals
ISBN: 0130085391
EAN: 2147483647
Year: 2005
Pages: 92

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net