Page 276 - Beginning PHP 5.3
P. 276
Part III: Using PHP in Practice
<label for=”newsletterFunWithWidgets”>Do you want to receive our
‘Fun with Widgets’ newsletter?</label>
<input type=”checkbox” name=”newsletter[]” id=”newsletterFunWith
Widgets” value=”funWithWidgets” />
<label for=”comments”>Any comments?</label>
<textarea name=”comments” id=”comments” rows=”4” cols=”50”>
</textarea>
<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>
Now save the following script as process_registration_multi.php in your document root folder:
<!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>
<?php
$favoriteWidgets = “”;
$newsletters = “”;
if ( isset( $_POST[“favoriteWidgets”] ) ) {
foreach ( $_POST[“favoriteWidgets”] as $widget ) {
$favoriteWidgets .= $widget . “, “;
}
}
if ( isset( $_POST[“newsletter”] ) ) {
foreach ( $_POST[“newsletter”] as $newsletter ) {
$newsletters .= $newsletter . “, “;
}
}
238
9/21/09 7:23:39 PM
c09.indd 238 9/21/09 7:23:39 PM
c09.indd 238