Specifications
Part of the HTML for this is shown in Listing 1.1. There are two important things to notice in
this code.
LISTING 1.1 orderform.html—HTML for Bob’s Basic Order Form
<form action=”processorder.php” method=post>
<table border=0>
<tr bgcolor=#cccccc>
<td width=150>Item</td>
<td width=15>Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align=center><input type=”text” name=”tireqty” size=3 maxlength=3></td>
</tr>
<tr>
<td>Oil</td>
<td align=center><input type=”text” name=”oilqty” size=3 maxlength=3></td>
</tr>
<tr>
<td>Spark Plugs</td>
<td align=center><input type=”text” name=”sparkqty” size=3 maxlength=3></td>
</tr>
<tr>
<td colspan=2 align=center><input type=submit value=”Submit Order”></td>
</tr>
</table>
</form>
The first thing to notice is that we have set the form’s action to be the name of the PHP script
that will process the customer’s order. (We’ll write this script next.) In general, the value of the
ACTION attribute is the URL that will be loaded when the user presses the submit button. The
data the user has typed in the form will be sent to this URL via the method specified in
the METHOD attribute, either GET (appended to the end of the URL) or POST (sent as a separate
packet).
The second thing you should notice is the names of the form fields—tireqty, oilqty, and
sparkqty. We’ll use these names again in our PHP script. Because of this, it’s important to
give your form fields meaningful names that you can easily remember when you begin writing
the PHP script. Some HTML editors will generate field names like field23 by default. These
are difficult to remember. Your life as a PHP programmer will be easier if these names reflect
the data that is typed into the field.
Using PHP
P
ART I
12
03 7842 CH01 3/6/01 3:39 PM Page 12