The query parameters in the URLs embedded in Example 15-14 were hardcoded in the
page’s HTML. But such URLs can also be generated automatically by a CGI script as
part of a reply page in order to provide inputs to the script that implements a next step
in user interaction. They are a simple way for web-based applications to “remember”
things for the duration of a session. Hidden form fields, up next, serve some of the same
purposes.
Passing Parameters in Hidden Form Fields
Similar in spirit to the prior section, inputs for scripts can also be hardcoded in a page’s
HTML as hidden input fields. Such fields are not displayed in the page, but are trans-
mitted back to the server when the form is submitted. Example 15-15, for instance,
allows a job field to be entered, but fills in name and language parameters automatically
as hidden input fields.
Example 15-15. PP4E\Internet\Web\tutor5d.html
Common input devices: hidden form fields
This demo invokes the tutor5.py server-side script again,
but hardcodes input data in the form itself as hidden input
fields, instead of as parameters at the end of URL hyperlinks.
As before, the text of this form, including the hidden fields,
can be generated as part of the page output by another CGI
Figure 15-18. Response page created by tutor5.py (3)
1172 | Chapter 15: Server-Side Scripting