What is Your Favorite Fruit?
Select your favorite fruit from the drop-down menu.
Array ( )
Array ( )
<?php
include('includes/header.php');
error_reporting(E_ALL);
$option = '';
$s = ' SELECTED ';
if (isset($_POST['option']))
{
$option = $_POST['option'];
}
?>
<h1>What is Your Favorite Fruit?</h1>
<h2>Select your favorite fruit from the drop-down menu.</h2>
<div class="full">
<form action="" method="post">
<fieldset>
<select name="option">
<option value="pineapple" <?php if ($option == 'pineapple')
{
echo ($s);
} ?> >Pineapple
</option>
<option value="apple" <?php if ($option == 'apple')
{
echo ($s);
} ?> >Apple
</option>
<option value="strawberry" <?php if ($option == 'strawberry')
{
echo ($s);
} ?> >Strawberry
</option>
<option value="cherry" <?php if ($option == 'cherry')
{
echo ($s);
} ?> >Cherry
</option>
<option value="mango" <?php if ($option == 'mango')
{
echo ($s);
} ?> >Mango
</option>
</select>
</fieldset>
<input type="submit" name="submit" value="submit">
</form>
</div>
<?php
echo("Favorite Fruit: $option");
echo('<pre>');
print_r($_POST);
echo('</pre>');
include('includes/footer.php');
?>