Create a form and check form variable in PHP
Description
The following code shows how to create a form and check form variable.
Example
/*from ww w . ja v a 2s. c o m*/
<?php
print("<html>\n");
print("<body>\n");
if(isset($_REQUEST['part']))
{
print("<h3>Last Burger</h3>\n");
print("<ul>\n");
foreach($_REQUEST['part'] as $part)
{
print("<li>$part</li>\n");
}
print("</ul>\n");
}
$option = array("mustard", "ketchup",
"pickles", "onions", "lettuce", "tomato");
print("<h3>Create a Burger</h3>\n");
print("<form action=\"{$_SERVER['PHP_SELF']}\">\n");
foreach($option as $o)
{
print("<input type=\"checkbox\" " .
"name=\"part[]\" value=\"$o\">" .
"$o<br>\n");
}
print("<input type=\"submit\">\n");
print("</form>\n");
print("</body>\n");
print("</html>\n");
?>
The code above generates the following result.