<?php
include('../includes/header.php');
// show errors
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
echo("<h1>Ernest's \$_POST form</h1>");
// set variables
$step = isset($_POST['step']) ? $_POST['step'] : 0;
$name = isset($_POST['name']) ? $_POST['name'] : '';
$phone = isset($_POST['phone']) ? $_POST['phone'] : '';
// sanitize
$step = htmlentities($step);
$name = htmlentities($name);
$phone = htmlentities($phone);
if ($step == 0) {
?>
<form action="post_form.php" method="POST" class="pad">
<label for="name">Name</label>
<input type="text" size="36" id="name" name="name" value="">
<br><br>
<label for="phone">Phone</label>
<input type="text" size="36" id="phone" name="phone" value="">
<br><br>
<input type="hidden" name="step" value="1">
<input type="submit" name="submit" value="Submit">
</form>
<?php
} else {
echo("<p>The following is what the form gathered</p>");
echo("<pre>");
print_r($_POST);
echo("</pre>");
?>
<form action="post_form.php" method="POST">
<input type="hidden" name="step" value="0">
<input type="submit" name="submit" value="Try Again">
</form>
<?php
}
include('../includes/footer.php');
?>