Steph's Sticky form
Count 1 (via hidden input)
<?php
//Gather the $_POST variables.
// Turnary - If first name is set then use it otherwise get it else use 0.
$isFirstTime = isset($_POST['isFirstTime']) ? $_POST['isFirstTime'] : 0;
$firstName = isset($_POST['firstName']) ? $_POST['firstName'] : '';
$lastName = isset($_POST['lastName']) ? $_POST['lastName'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$phone = isset($_POST['phone']) ? $_POST['phone'] : '';
//Filter input taken from the browser/sanitizes input
$isFirstTime = htmlentities($isFirstTime);
$firstName = htmlentities($firstName);
$lastName = htmlentities($lastName);
$email = htmlspecialchars($email);
$phone = htmlentities($phone);
// The counter on the submit button
$hiddenVarCounter = $_POST['hiddenVarCounter'] ?? 0;
$hiddenVarCounter ++;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Get</title>
<!-- Header, footer, and primary layout styles also used in other files -->
<link rel="stylesheet" href="../css/assignmentHeaderStyles.css" />
<!-- Specific form styling -->
<link rel="stylesheet" href="../css/week3Assignment.css" />
</head>
<body>
<?php
// Include header inside the <body> so Flexbox tracks it correctly and its not all weird.
include ('../header/assignmentHeader.php');
?>
<!-- Main wrapper fills the screen space and pushes footer down -->
<main class="site-main container">
<h1>Steph's Sticky form</h1>
<!-- Leaving the action empty will cause the page to not advance when the submit it clicked-->
<form action="" method="POST" class="colectingPersonalInformation">
<label for="FirstName">First Name</label>
<input type="text" size="36" id="FirstName" name="firstName" value="<?php echo $firstName; ?>">
<br><br>
<label for="lastName">Last Name</label>
<input type="text" size="36" id="lastName" name="lastName" value="<?php echo $lastName; ?>">
<br><br>
<label for="email">Email</label>
<input type="email" size="36" id="email" name="email" value="<?php echo $email; ?>">
<br><br>
<label for="phone">Phone</label>
<input type="text" size="36" id="phone" name="phone" value="<?php echo $phone; ?>">
<br><br>
<input type="hidden" name="isFirstTime" value="1">
<input type="hidden" name="hiddenVarCounter" value="<?php echo($hiddenVarCounter); ?>">
<input type="submit" name="submit" value="Submit">
</form>
<?php
echo("<br>Count $hiddenVarCounter (via hidden input) <br>");
?>
<?php
// This will display the source code of the file
show_source(__FILE__);
?>
</main>
<?php
// Putting the footer at the bottom of the body puts the footer at the bottom of the page as it should be.
include ('../footer/footer.php');
?>
</body>
</html>