CODE FOLLOWS
<?php
include('includes/header.php');
// 1. IMPORTANT: session_start() must be at the very top of the file
session_start();
$message = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// 2. Store the user's input into a SESSION variable
$_SESSION['fav_color'] = $_POST['color'];
$_SESSION['user_name'] = $_POST['name'];
$message = "Session variables have been set! <a href='session_viewer.php'>Go to Page 2</a> to see them persist.";
}
include('includes/footer.php');
?>
<!DOCTYPE html>
<html lang="en">
<head><title>Tony's Setting Sessions</title></head>
<body>
<h2>Session Data Entry</h2>
<form method="post" action="">
Name: <label>
<input type="text" name="name" required>
</label><br><br>
Favorite Color:
<label>
<select name="color">
<option value="Blue">Blue</option>
<option value="Green">Green</option>
<option value="Red">Red</option>
</select>
</label><br><br>
<input type="submit" value="Save to Session">
</form>
<p><?php echo $message; ?></p>
</body>
</html>