[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1
<table border=1>
<tr>
<td>0.0</td>
<td>0.1</td>
<td>0.2</td>
<td>0.3</td>
</tr>
<tr>
<td>1.0</td>
<td>1.1</td>
<td>1.2</td>
<td>1.3</td>
</tr>

</table>

Other table tags and options let us specify a row title (), lay out borders, and so
on. We’ll use more table syntax to lay out forms in a uniform fashion later in this
tutorial.


Adding User Interaction


CGI scripts are great at generating HTML on the fly like this, but they are also com-
monly used to implement interaction with a user typing at a web browser. As described
earlier in this chapter, web interactions usually involve a two-step process and two
distinct web pages: you fill out an input form page and press Submit, and a reply page
eventually comes back. In between, a CGI script processes the form input.


Submission page


That description sounds simple enough, but the process of collecting user inputs re-
quires an understanding of a special HTML tag,

. Let’s look at the implementa-
tion of a simple web interaction to see forms at work. First, we need to define a form
page for the user to fill out, as shown in Example 15-6.


Example 15-6. PP4E\Internet\Web\tutor3.html



CGI 101

A first user interaction: forms





Enter your name:





Climbing the CGI Learning Curve| 1149
Free download pdf