Luis's All in One form
Results
Array ( )
Array ( )
<?php
include('includes/header.php');
// FOUND bug here it was orignally "server_name" dont work then had to switch to current"openssl_tl etc name"
$self = htmlspecialchars(basename($_SERVER[OPENSSL_TLSEXT_SERVER_NAME]));
// populate the fruit array
$fruit = array("Apple", "Pear", "Orange", "Mango", "Apricot", "Pineapple");
// populate vars from POST
$submit = isset($_POST['submit']) ? $_POST['submit'] : null;
$first_name = isset($_POST['first_name']) ? $_POST['first_name'] : null;
$last_name = isset($_POST['last_name']) ? $_POST['last_name'] : null;
$full_time = isset($_POST['full_time']) ? $_POST['full_time'] : null;
$admin = isset($_POST['admin']) ? $_POST['admin'] : null;
// populate choice from radio input
if (isset($_POST['choice']))
{
$choice = $_POST['choice'];
}
else
{
$choice = '';
}
// populate option array from select control
$option = array();
if (isset($_POST['option']))
{
foreach ($_POST['option'] as $value)
{
$option[] = $value;
}
}
// populate option array from select control
$option2 = array();
if (isset($_POST['option2']))
{
foreach ($_POST['option2'] as $value)
{
$option2[] = $value;
}
}
// set what was checked
$s = ' SELECTED ';
$c = ' CHECKED ';
$full_time = ($full_time == 'on') ? $c : '';
$admin = ($admin == 'on') ? $c : '';
?>
<h1>Luis's All in One form</h1>
<form action="<?php echo($self); ?>" method="post">
<fieldset>
<legend>Text:</legend>
<label for="first_name">First Name</label>
<input type="text" size="30" id="first_name" name="first_name" value="<?php echo($first_name); ?>">
<br>
<label for="last_name">Last Name</label>
<input type="text" size="30" id="last_name" name="last_name" value="<?php echo($last_name); ?>">
</fieldset>
<br>
<fieldset>
<legend>Checkbox:</legend>
<label for="full_time">Full Time</label>
<input type="checkbox" id="full_time" name="full_time" <?php echo($full_time); ?> >
<br>
<label for="admin">Admin</label>
<input type="checkbox" id="admin" name="admin" <?php echo($admin); ?> >
</fieldset>
<br>
<fieldset>
<legend>Radio:</legend>
<label for="choice">Fruit</label>
<br>
<input type="radio" id="choice" name="choice" value="Apple"
<?php if ($choice == 'Apple')
{
echo($c);
} ?> > Apple🍎<br>
<input type="radio" id="choice" name="choice" value="Pear"
<?php if ($choice == 'Pear')
{
echo($c);
} ?> > Pear🍐<br>
<input type="radio" id="choice" name="choice" value="Orange"
<?php if ($choice == 'Orange')
{
echo($c);
} ?> > Orange🍊<br>
<input type="radio" id="choice" name="choice" value="Mango"
<?php if ($choice == 'Mango')
{
echo($c);
} ?> > Mango🥭<br>
<input type="radio" id="choice" name="choice" value="Grapes"
<?php if ($choice == 'Grapes')
{
echo($c);
} ?> > Grapes🍇<br>
</fieldset>
<br>
<fieldset>
<legend>Dropdown:</legend>
<label for="option[]">Protien Flavor Shakes</label>
<br>
<select id="option[]" name="option[]">
<option value="Choclate" <?php if (in_array('Choclate', $option))
{
echo($s);
} ?> >Choclate🍫
</option>
<option value="Vanilla" <?php if (in_array('Vanilla', $option))
{
echo($s);
} ?> >Vanilla🍦
</option>
<option value="Carmel" <?php if (in_array('Carmel', $option))
{
echo($s);
} ?> >Carmel🍬
</option>
<option value="Strawberries" <?php if (in_array('Strawberries', $option))
{
echo($s);
} ?> >Strawberries🍓
</option>
<option value="CookieDough" <?php if (in_array('CookieDough', $option))
{
echo($s);
} ?> >CookieDough🍪
</option>
</select>
</fieldset>
<br>
<fieldset>
<legend>Multiple:</legend>
<label for="option2[]">Games</label>
<br>
<select id="option2[]" name="option2[]" multiple>
<option value="Minecraft" <?php if (in_array('Minecraft', $option2))
{
echo($s);
} ?> >Minecraft
</option>
<option value="Fortnite" <?php if (in_array('Fortnite', $option2))
{
echo($s);
} ?> >Fortnite
</option>
<option value="MarvelRivals" <?php if (in_array('MarvelRivals', $option2))
{
echo($s);
} ?> >MarvelRivals
</option>
<option value="Overwatch" <?php if (in_array('Overwatch', $option2))
{
echo($s);
} ?> >Overwatch
</option>
<option value="Valorant" <?php if (in_array('Valorant', $option2))
{
echo($s);
} ?> >Valorant
</option>
</select>
</fieldset>
<br>
<br>
<input type="submit" name="submit" value="Submit">
</form>
<br>
<h2>Results</h2>
<br>
<?php
// show results
echo('<pre>');
print_r($_POST);
echo('</pre>');
include('includes/footer.php');
?>