Hidden Fields in Forms

As you learned back in Hour 5, “Creating HTML Forms,” you can use hidden form fields in your forms. Each of these fields contains a name and value that is passed to the CGI script along with the other visible form fields. You can use these hidden form fields to save the state of a transaction from one form to the next, as you saw in the previous lesson.

Let’s say you’re building a Web page that allows a user to register, and you want to ask the user additional questions based on the information he provides in the registration form. If the user responds that he has a TV in his home, you may want to ask how much TV he watches in a week. If he has a dog, you could ask what his favorite brand of dog food is.

In order to store ...

Get Sams Teach Yourself CGI in 24 Hours, Second Edition 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.