<html>
<head>
<title>Process an HTML form</title>
</head>
<body>
<?php include "../include.php"; ?> <!-- hyperlink to see the code -->
<?php
error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE); //all but warnings & notices
//----- Retrieve form elements ---------------------------------------------
$firstname = $_POST['firstname']; #get HTML form entry fields
$lastname = $_POST['lastname'];
$address = $_POST['address'];
$flavor = $_POST['flavor']; #select list array
$topping = $_POST['topping']; #checkboxes array
$creditCard = $_POST['creditCard'];
if (is_array($flavor)) #select list
$flavor = implode(',' , $flavor);
if (is_array($topping)) #checkboxes
$topping = implode(',' , $topping);
if (!$firstname) {
print "<font color=red>Please enter First Name</font>";
exit;
}
if (!$lastname) {
print "<font color=red>Please enter Last Name</font>";
exit;
}
if (!$address) {
print "<font color=red>Please enter your Address</font>";
exit;
}
if (!$flavor) {
print "<font color=red>Please choose ice cream flavor(s)</font>";
exit;
}
if (!$topping) {
print "<font color=red>Please select topping(s)</font>";
exit;
}
if (!$creditCard) {
print "<font color=red>Please select Credit Card</font>";
exit;
}
print "<table bgcolor=lightyellow border=2> \n";
print "<tr bgcolor=tan> \n";
print "<th>Element Name</th><th>Element Value</th> \n";
print "<tr><th>Firstname</th> <td>$firstname </td> \n";
print "<tr><th>Lastname</th> <td>$lastname </td> \n";
print "<tr><th>Address</th> <td>$address </td> \n";
print "<tr><th>Flavor</th> <td>$flavor </td> \n";
print "<tr><th>Topping</th> <td>$topping </td> \n";
print "<tr><th>Credit Card</th> <td>$creditCard </td> \n";
print "</table>";
?>
</body>
</html>