Re: use SESSION variable?
- From: sheldonlg <sheldonlg>
- Date: Mon, 30 Jun 2008 06:07:32 -0400
Tim Roberts wrote:
"Twayne" <nobody@xxxxxxxxxxxxxxxxxxx> wrote:My actual question is: How do I get a POST variable into a session variable so I can use it in any other page I want to use it in?
Apparently posted variables are only available in the Form page in the file called by Action=, right? But I'd like to use it in other places.
There are several ways to do this. A $_SESSION variable is one way, and in
many cases that's the most convenient. However, if you have a bunch of
pages with <form>s that succeed one another, it's also possible to pass
this kind of information as <input type=hidden> variables without the
overhead of a session.
To expand in what Tim wrote, here is what you would do in 2.php
<input type="hidden" value="<?php print $_POST['age']; ?>" >
to get the value from 1.php. Then in 3.php you would be able to get it from the $_POST['age'] coming from 2.php.
I prefer using a session variable for situations where I need it on multiple pages because then I don't have to worry about the exact order of the pages.
.
- Follow-Ups:
- Re: use SESSION variable?
- From: Michael Fesser
- Re: use SESSION variable?
- References:
- use SESSION variable?
- From: Twayne
- Re: use SESSION variable?
- From: Tim Roberts
- use SESSION variable?
- Prev by Date: Re: how to store the path of uploading file....
- Next by Date: Re: php execution time
- Previous by thread: Re: use SESSION variable?
- Next by thread: Re: use SESSION variable?
- Index(es):