Specifications
You might want to consider adopting a coding standard for field names so that all field names
throughout your site use the same format. This makes it easier to remember whether, for exam-
ple, you abbreviated a word in a field name, or put in underscores as spaces.
Processing the Form
To process the form, we’ll need to create the script mentioned in the ACTION attribute of the
FORM tag called processorder.php. Open your text editor and create this file. Type in the fol-
lowing code:
<html>
<head>
<title>Bob’s Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob’s Auto Parts</h1>
<h2>Order Results</h2>
</body>
</html>
Notice, how everything we’ve typed so far is just plain HTML. It’s now time to add some sim-
ple PHP code to our script.
Embedding PHP in HTML
Under the <h2> heading in your file, add the following lines:
<?
echo “<p>Order processed.”;
?>
Save the file and load it in your browser by filling out Bob’s form and clicking the Submit but-
ton. You should see something similar to the output shown in Figure 1.2.
Notice how the PHP code we wrote was embedded inside a normal-looking HTML file. Try
viewing the source from your browser. You should see this code:
<html>
<head>
<title>Bob’s Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob’s Auto Parts</h1>
<h2>Order Results</h2>
<p>Order processed.</p></body>
</html>
PHP Crash Course
C
HAPTER 1
1
PHP CRASH
COURSE
13
03 7842 CH01 3/6/01 3:39 PM Page 13