passing form variables to several pages?


#1

I am trying to have my users make a series of choices. On page one they type comments into a form textarea. On page two the user makes a series of choices. At page three I want to show what the user typed on page one, and the choices made on page two. My problem is passing the text typed into the form from page one, to page three. Using echo $_post[var_name] I can get the typed info from the form to appear on page two, but it won’t show on page three. So, long story short… here’s my question. How can I pass form variables over several pages???


#2

There are two ways of doing it, either resend the info from page one to page three from page two or do the easy thing by typing session_start() at the top of each of the three pages and assign the $_SESSION variable like so:

[php]
$_SESSION[‘var_name’] = $_POST[‘var_name’];
[/php]

The information will stay in the $_SESSION array until the session expires, usually around 3 hrs, or you unset the array:

[php]
unset($_SESSION[‘var_name’]);
[/php]

Hope this helps.


#3

OpzMaster,
Thanks for the response but this doesnt seem to do it. I have session_start() on each page. I can pass the username variable through all pages with no prob, but not the text from the form. When I define my variables how do I link that definition with the textarea from the form. I only want to carry over as my variable the text that the user typed in. here is part of the code for the form:

To create the variable would I am using:

$_SESSION[‘sizeup’] = $_POST[‘sizeup’];

to recal the variable on later pages I am using:

echo $_SESSION[‘sizeup’]

I am a rookie at this, and really can’t figure out where I’m going wrong.