user4fun Posted March 4, 2006 Share Posted March 4, 2006 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 More sharing options...
sbrownii Posted March 4, 2006 Share Posted March 4, 2006 You can eitherpass your variable from page to page by adding to the query stringOr use sessions Link to comment Share on other sites More sharing options...
user4fun Posted March 4, 2006 Author Share Posted March 4, 2006 i am not sure what you mean sir, can you please maybe give me more details Link to comment Share on other sites More sharing options...
sbrownii Posted March 4, 2006 Share Posted March 4, 2006 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 More sharing options...
Douglas Posted March 5, 2006 Share Posted March 5, 2006 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 More sharing options...
DarkElf Posted March 5, 2006 Share Posted March 5, 2006 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 More sharing options...
user4fun Posted March 5, 2006 Author Share Posted March 5, 2006 fantastic! thank you for the explanation and taking the time. Link to comment Share on other sites More sharing options...
user4fun Posted March 6, 2006 Author Share Posted March 6, 2006 geeeez, the number of things you can do with sessions is awesome.thank you all for taking me to the next level of phpfrom beginner, to beginning. lol Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now