On the form page I have the following:
<?php
session_start();
if (isset($_POST['submit'])){
$_SESSION['username'] = $_POST['username'];
}
?>
<form action="index.php">
<input type="text" name="username">
<input type="submit" name="submit">
</form>
On the file 'index.php' I have:
<?php
session_start();
echo ($_SESSION['username']);
?>
But the output on the index page says that the session variable is undefined. How do I fix this and why is it undefined?