<HTML>
<HEAD>
<TITLE> Example 4 </TITLE>
</HEAD>
<?
// Initialize variables from form
$name = $_POST['name'];
$favcolor = $_POST['favcolor'];
$yearborn = $_POST['yearborn'];
// encode any special characters in these variables
$encoded_name = htmlentities($name);
$encoded_favcolor = htmlentities($favcolor);
// print the body tag containing the person's favorite color
// as a background
print("<body bgcolor=$encoded_favcolor>");
// print the person's name
print("Hello $encoded_name<br>");
// Get the current date and store it in $currentdate, an array
// Retrieve the year from the $currentdate array and store it in
// a variable called $year, this will be used in calculating the age
$currentdate = getdate();
$year = $currentdate["year"];
// Calculate age using the $yearborn field from the submitted form
$age = $year - $yearborn;
// print the person's age
print("You are $age years old");
?>
</BODY>
</HTML>