Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/142062-solved-sessions-and-variables/
Share on other sites

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']";
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.