I have a webpage with a form on it.
I use this php code to put the value of the form in sessions when de _POST method is activated:
<?php session_start(); ?>
<?php
$dump ='';
$dump .='<!DOCTYPE html>
<html>
<head></head>
<body>';
$dump .='
<h1>Deel 1: registratiegegevens</h1>
<form action="oplossing21-deel2.php" method="post">
<ul>
<li> <label for="email">email: </label><input type="text" name="email" id="email" value="'.$email.'" />
</li>
<br />
<li> <label for="nickname">nickname: </label><input type="text" name="nickname" id="nickname" />
</li>
<br />
<li> <input type="submit" value ="volgende" />
</li>
</ul>
</form>
';
if ($_POST) {
// Store our name in the session array
$_SESSION["email"] = $_POST["email"];
$_SESSION["nickname"] = $_POST["nickname"];
}
$email = isset($_SESSION["email"]) ? $_SESSION["email"] : "leeg";
$dump .='
</body>
</html>';
echo $dump;
?>
Now i want to know how i can make sure that if i reload the page (F5 or cmd+r), that the fields are filled in with the last typed values. So i submit the form, and i go to the next page, but when i come back, i want the input fields to be filled in with the last known value. Can someone help me with this? I already tried to do something with the isset() - function but i don't know where to go from here.
on the second page i just put the sessions on the html file, and that works..
<li>'.$_POST["email"].'</li>