I am working with sessions When I submit my form from page 1 to page 2, on page 2 I keep getting the notice of undefined variable. Do you all see something I don't ? Also I am only putting pertinent HTML. Thank you!
P.S. - (I read the similar posts but they do not answer my question they only mention checking the assignment operators. Also, I looked at the example that says “already answered here” but it does not help me because in that stackoverflow post it is assuming I know what the username is. In my case it is different because the username is whatever the user enters, it’s not predetermined by me! )
PAGE 1: HTML/PHP
<form action="L10_Combo2.php" method="POST">
<p>Please enter your username</br>
<input type="text" id="username" name="username"/>
</p>
<p>Please enter your email address</br>
<input type="email" id="email" name="email"
</p>
</br></br>
<input type="submit" name="submit" value="Submit Information"/>
</form>
<?php
session_start();
if(isset($_POST['submit'])){
$username = $_SESSION['username'];
$email = $_SESSION['email'];
}
?>
PAGE 2: L10_Combo2
<?php
session_start();
if(isset($_SESSION['username']) && isset($_SESSION['email'])){
$username = $_SESSION['username'];
$email = $_SESSION['email'];
}
//This is where I am getting the undefined variable error!
print("Stored in the session: " . $username . $email);
session_destroy();