Chapter 20. Processing Web Input with MySQL
The previous chapter describes how to retrieve information from MySQL and display it in web pages using HTML constructs such as tables or hyperlinks. That’s a use of MySQL to send information in one direction (from web server to user). This chapter considers the use of MySQL in the other direction: web-based database programming to collect information sent from user to web server, such as the contents of a submitted form. For example, you might store the information from a survey form for later use, or use keywords from a lookup form as the basis for a query to search the database for information the user wants.
MySQL comes into these activities as the repository for storing information or as the source from which search results are drawn. But before you can process input from a form, you must create the form and send it to the user. MySQL helps with this, too, because it’s often possible to use information from your database to generate form elements such as radio buttons, checkboxes, pop-up menus, or scrolling lists:
Select a set of items from a table that lists countries, states, or provinces and convert them into a pop-up menu in a form that collects address information.
Use the list of legal values for an
ENUMcolumn that contains permitted colors or sizes to generate a set of radio buttons.
Use lists of available colors, sizes, or styles stored in an inventory database to construct fields for a clothing ordering form.