jnerotrix Posted January 23, 2009 Share Posted January 23, 2009 i have a website but and a form they input the data but i need the data they input into the form into a session so the variable is not forgotten so lets say it was like this <?php <form action="2.php" method="post"> NAME: <input type="text" name="1"><br> <input type="submit" value="go"> </form> ?> NEXT PAGE <?php session_start(); $name = $_POST['1']; echo "hello $name"; ?> <a href="./3.php">GOTO THE NEXT PAGE</a> 3d PAGE <?php session_start(); $name = $_POST['1']; echo "hello $name"; ?> Bassicaly i need it to save the inputed data into a session thats rememberd over a series of pages Quote Link to comment https://forums.phpfreaks.com/topic/142062-solved-sessions-and-variables/ Share on other sites More sharing options...
phparray Posted January 23, 2009 Share Posted January 23, 2009 Your are correct to call session_start(); at the top of each page. You just haven't added anything to the session array yet. That is done like so. <?php session_start(); $_SESSION['name'] = $_POST['1']; echo "hello $_SESSION['name']"; ?> <a href="./3.php">GOTO THE NEXT PAGE</a> <?php session_start(); echo "hello $_SESSION['name']"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/142062-solved-sessions-and-variables/#findComment-743963 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.