8. Multiple Form Interaction
One of the problems with the current HTTP protocol is its inability to maintain state. In other words, the protocol provides no way to access data from previous requests.
Imagine an ordering (or “shopping cart”) system on the Web. You present the user with several forms listing the numerous products that can be ordered. The system keeps track of what the user ordered. Finally, it displays all of the user's selections. This type of system needs to somehow store the information--or “state”--so that it can be accessed at a later time.
For example, suppose you ask the user for his or her address in the first form. If you need this information in a later form, you don't want to ask all over again. Instead, you want to find a way for that address to be accessible to a later form, but transparent to the user. This is the most basic problem of using multiple forms--maintaining “state” from one form to another--and thus deserves special attention in this book.
There are several different strategies we'll explore for maintaining state. They include:
- Hidden fields. Using hidden fields, you can embed information into a form that the user won't see, but which will be sent back to the CGI program when the form is submitted.
- CGI Side Includes. This is a mechanism by which we embed special tags into the HTML document that pass CGI variables invisibly.
- Netscape Persistent Cookies. The Netscape browser supplies a method for storing and retrieving information via CGI. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access