<?php
include('../includes/header.php');
// error reporting
error_reporting(E_ALL);
echo('<h1>Allies\'s $_GET form</h1>');
// if step is set then assign step to $step else assign 0 for first visit
$step = isset($_GET['step']) ? $_GET['step'] : 0;
// if name is set then assign name to $name else assign ''
$name = isset($_GET['name']) ? $_GET['name'] : '';
// if phone is set then assign phone to $phone else assign ''
$type = isset($_GET['type']) ? $_GET['type'] : '';
// filter all input taken from the Browser
$step = htmlentities($step);
$name = htmlentities($name);
$type = htmlentities($type);
// if first time into form show the input form
if ($step == 0)
{
?>
<form action="getform.php" method="GET" class="pad">
<label for="name">Pet Name</label>
<input type="text" id="name" size="30" name="name" value="">
<br><br>
<label for="type">Pet Type(Cat, Dog, etc)?</label>
<input type="text" id="type" size="17" name="type" value="">
<br><br>
<!-- sets steps to 1 so the form goes to the user input screen -->
<input type="hidden" name="step" value="1">
<input type="submit" name="submit" value="Submit">
</form>
<?php
}
// else show the information gathered and a try again form
else
{
echo('<p>The following is what the form gathered</p>');
echo('<pre>');
// show the contents of the POST array
print_r($_GET);
echo('</pre>');
// provide a form to try again
?>
<form action="getform.php" method="GET">
<!-- sets steps to 0 so the form goes to the user input screen -->
<input type="hidden" name="step" value="0">
<input type="submit" name="submit" value="Try Again">
</form>
<?php
}
include('../includes/footer.php');
?><?php