tutor3.html is a simple HTML file, not a CGI script (though its contents could be printed
from a script as well). When this file is accessed, all the text between its
Figure 15-6. A simple form page generated by tutor3.html
More on form tags
We won’t go into all the details behind coding HTML forms, but a few highlights are
worth underscoring. The following occurs within a form’s HTML code:
Form handler action
The form’s action option gives the URL of a CGI script that will be invoked to
process submitted form data. This is the link from a form to its handler program—
in this case, a program called tutor3.py in the cgi-bin subdirectory of the locally
running server’s working directory. The action option is the equivalent of
command options in tkinter buttons—it’s where a callback handler (here, a remote
handler script) is registered to the browser and server.
Input fields
Input controls are specified with nested tags. In this example, input tags
have two key options. The type option accepts values such as text for text fields
and submit for a Submit button (which sends data to the server and is labeled
“Submit Query” by default). The name option is the hook used to identify the en-
tered value by key, once all the form data reaches the server. For instance, the
server-side CGI script we’ll see in a moment uses the string user as a key to get the
data typed into this form’s text field.
As we’ll see in later examples, other input tag options can specify initial values
(value=X), display-only mode (readonly), and so on. As we’ll also see later, other
1150 | Chapter 15: Server-Side Scripting