Jump to content

variables


user4fun

Recommended Posts

how long can a variable be moved from page to page.reasonpage 1 = user input then clicks command buttongoes to page 2 = variable has moved and query took place then another command button.goes to page 3, which i would like it to do another query on the same variable but by page three the variable does not exsists??how can i keep it and move it from page 2 to page 3

Link to comment
Share on other sites

for sessions... search for tutorials on the webfor passing variables via query string... you could use a hidden element in the form to store variables from previous pages... you could set the value of that element using php, or javascript, or whatever...I'm pretty sure you can figure it out... or you can figure a way to do what you are doing without needing to keep passing the same variable around...

Link to comment
Share on other sites

Like this:

<?phpsession_start();$_SESSION['name']="This will be passed on.";?>

Now take this one:

<?phpsession_start();echo $_SESSION['name'];?>

Now upload those two on your server, go to the first one, then go to the second one, and it will show you what the value of the session is. Make sense?

Link to comment
Share on other sites

Douglas' example is probably the easiest way to do it. I had a page in which I wanted to do pretty much exactly the same as you are and used sessions for it.The really good thing about the session variable is that you don't need to keep passing it from one page to another, once set it remains set until you either unset it or the session ends. It is also open to any page or script that looks for it, unlike post which is only available on the page it is submitted to.The session ends when the user closes the browser window, rather like post variables or cookies the session variable is stored in the users browser, the difference is when the variable ends (cookies can last for variable lengths of time, they can expire at the end of the session, they can expire after a fixed window of time, or they can last forever. Post variables on the other hand only last whilst the page that uses them is open).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...