asked on
// tunaSurvey.php
<html>
<head>
<title>Tuna Cafe</title>
</head>
<body>
<font size="4" color="blue">Welcome to the Tuna Cafe Survey!</font>
<form action="tunaResults.php" method="POST">
<?php
$menu = array('Tuna Casserole', 'Tuna Sandwich', 'Tuna Pie', 'Grilled Tuna', 'Tuna Surprise');
$bestSeller = 2;
print 'Please indicate all your favorite dishes.<br />';
for ($i=0; $i < count($menu); $i++)
{
print "<input type=\"checkbox\" name=\"prefer[]\" value=\"$i\"> $menu[$i]";
if ($i == $bestSeller)
{
print '<font color="red">Our best Seller!!!</font>';
}
print '<br/>';
}
?>
<input type="submit" value="Click to submit">
<input type="reset" value="Erase and Restart">
</form>
</body>
</html>
//tunaResults.php
<html>
<head>
<title>Tuna Cafe</title>
</head>
<body>
<font size="4" color="blue">Tuna Cafe Results received</font>
<?php
$menu = array('Tuna Casserole', 'Tuna Sandwich', 'Tuna Pie', 'Grilled Tuna', 'Tuna Surprise');
if (count($_POST["$prefer"]) != 0){
print '<br />Your selection were <ul>';
foreach ($prefer as $item){
print "<li>$menu[$item]</li>";
}
} else {
print "You don't like our food?";
}
print '</ul>';
?>
</body>
</html>