Retrieve $_SESSION Value In Input Value
I am working with a basic registration form , if the user presses submit button , i want to store the input values to a session and also to retain the same user data into the input
Solution 1:
this <?php session_start(); ?> should come right on top of the page before everything else!
it should start like this;
<?php session_start(); ?>
<!DOCTYPE html>
you should be getting a php error right now saying "Fatal error; headers already sent" or something like that.
the $_SESSION variable will not be available to you if the server did not get the instruction session_start(); in the very first line of your code
Solution 2:
Move this part at the top of your script, just after session_start(); :
<?php
if (isset($_POST['submit']))
{
$_SESSION['user'] = $_POST['user'];
$_SESSION['email'] = $_POST['email'];
}
?>
Also, as @pythonian29033 said, session_start(); should be written before you output any content.
Post a Comment for "Retrieve $_SESSION Value In Input Value"