Page 270 - Beginning PHP 5.3
P. 270
Part III: Using PHP in Practice
<div style=”clear: both;”>
<input type=”submit” name=”submitButton” id=”submitButton”
value=”Send Details” />
<input type=”reset” name=”resetButton” id=”resetButton”
value=”Reset Form” style=”margin-right: 20px;” />
</div>
</div>
</form>
</body>
</html>
Next, save the following script as process_registration.php in your document root (the folder
where you placed registration.html), then open the registration.html URL in your Web
browser. Fill in the fields in the form, then click the Send Details button. If all goes well, you should
see a page displaying the data that you just entered.
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>Thank You</title>
<link rel=”stylesheet” type=”text/css” href=”common.css” />
</head>
<body>
<h1>Thank You</h1>
<p>Thank you for registering. Here is the information you submitted:</p>
<dl>
<dt>First name</dt><dd><?php echo $_POST[“firstName”]?></dd>
<dt>Last name</dt><dd><?php echo $_POST[“lastName”]?></dd>
<dt>Password</dt><dd><?php echo $_POST[“password1”]?></dd>
<dt>Retyped password</dt><dd><?php echo $_POST[“password2”]?></dd>
<dt>Gender</dt><dd><?php echo $_POST[“gender”]?></dd>
<dt>Favorite widget</dt><dd><?php echo $_POST[“favoriteWidget”]?></dd>
<dt>Do you want to receive our newsletter?</dt><dd><?php echo
$_POST[“newsletter”]?></dd>
<dt>Comments</dt><dd><?php echo $_POST[“comments”]?></dd>
</dl>
</body>
</html>
Figure 9-3 shows an example form just before it was submitted, and Figure 9-4 shows the result of
sending the form.
232
9/21/09 7:23:36 PM
c09.indd 232 9/21/09 7:23:36 PM
c09.indd 232