Chapter 5. Forms

Computers are like Old Testament gods; lots of rules and no mercy.

—Joseph Campbell

WHAT'S IN THIS CHAPTER?

  • Field validation.

  • Customizing forms.

  • Using Captcha as spam protection.

Input forms have become so common and natural that users probably do not even notice when they fill them in. There is also nothing strange about a form noticing that our e-mail address is incorrect or requesting us to write down some barely recognizable characters. This chapter explores forms: form creation and the various common tasks associated with them, such as customization and validation. Several automatic functions of frameworks regarding building forms and their validation are presented here as well.

Web forms can be found at various websites throughout the Internet. They are used in all sorts of situations, allowing users to pass data that is later processed by server-side scripts. By including forms in your web application, you allow visitors to register and enter their unique content. Furthermore, forms can also be used for ordering various products online, voting in polls, and other sorts of user input. In some situations, forms can also be used when you must implement some mechanisms to ensure the security of transmitted data. (More about form security and secured connections can be found in Chapter 8.) This chapter focuses on form validation and customization. We also discuss Captcha tests as a spam protection instrument.

FIELD VALIDATION

One of the most important parts of any ...

Get Building PHP Applications with Symfony™, CakePHP, and Zend® Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.