1.	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2.		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3.	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4.	<head>
5.		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6.		<title>Registration</title>
7.		<style type="text/css" media="screen">
8.			.error { color: red; }
9.		</style>
10.	</head>
11.	<body>
12.	<h2>Registration Results</h2>
13.	<?php // Script 6.5 - handle_reg.php #4
14.	/* This script receives eight values from register.html:
15.	email, password, confirm, month, day, year, color, submit */
16.	
17.	// Address error management, if you want.
18.	
19.	// Flag variable to track success:
20.	$okay = TRUE;
21.	
22.	// Validate the email address:
23.	if (empty($_POST['email'])) {
24.		print '<p class="error">Please enter your email address.</p>';
25.		$okay = FALSE;
26.	}
27.	
28.	// Validate the password:
29.	if (empty($_POST['password'])) {
30.		print '<p class="error">Please enter your password.</p>';
31.		$okay = FALSE;
32.	}
33.	
34.	// Check the two passwords for equality:
35.	if ($_POST['password'] != $_POST['confirm']) {
36.		print '<p class="error">Your confirmed password does not match the original password.</p>';
37.		$okay = FALSE;
38.	}
39.	
40.	// Validate the birthday:
41.	$birthday = '';
42.	
43.	// Validate the month:
44.	if (is_numeric($_POST['month'])) {
45.		$birthday = $_POST['month'] . '-';
46.	} else {
47.		print '<p class="error">Please select the month you were born.</p>';
48.		$okay = FALSE;
49.	}
50.	
51.	// Validate the day:
52.	if (is_numeric($_POST['day'])) {
53.		$birthday .= $_POST['day'] . '-';
54.	} else {
55.		print '<p class="error">Please select the day you were born.</p>';
56.		$okay = FALSE;
57.	}
58.	
59.	// Validate the year:
60.	if (is_numeric($_POST['year'])) {
61.		$birthday .= $_POST['year'];
62.	} else {
63.		print '<p class="error">Please enter the year you were born as four digits.</p>';
64.		$okay = FALSE;
65.	}
66.	
67.	// Check that they were born before 2009:
68.	if ($_POST['year'] >= 2009) {
69.		print '<p class="error">Either you entered your birth year wrong or you come from the future!</p>';
70.		$okay = FALSE;
71.	}
72.	
73.	// If there were no errors, print a success message:
74.	if ($okay) {
75.		print '<p>You have been successfully registered (but not really).</p>';
76.		print "<p>You entered your birthday as $birthday.</p>";
77.	}
78.	?>
79.	</body>
80.	</html>