reportingsjr Posted May 24, 2006 Share Posted May 24, 2006 How can I pass one variable from one page to another different page without using the GET function..? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 24, 2006 Share Posted May 24, 2006 First, GET isn't a function, in PHP it's just a variable.Anyway, is there a particular reason you don't want to use it? Your alternatives are to either store everything in the session, or to store just an ID number in the session, and store all of the information in a database or a file, and look it up using the ID in the session. Depending on what you're doing, you could also create and submit a form using javascript, but that obviously wouldn't work if javascript was disabled. Link to comment Share on other sites More sharing options...
pulpfiction Posted May 24, 2006 Share Posted May 24, 2006 Or you can use POST method to pass information to another page. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 24, 2006 Share Posted May 24, 2006 Right, if you create and submit a form, it goes through POST. Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 24, 2006 Share Posted May 24, 2006 SESSIONs are also possible, they are just like POST and GET superglobals. They work the same, only session variables must be manually set with a constructor, and the session itself must be initiated at the very beginning of every page that takes part. :)Session variables are kept the entire session, that ends after a period of inactivity of the user. There will be stored a cookie at the user's cache, that holds the session ID. The server then searches every session start folr present IDs, and continues that session. Link to comment Share on other sites More sharing options...
reportingsjr Posted May 24, 2006 Author Share Posted May 24, 2006 Well, im trying to create a text-based game.. and I need it to go through a login page, then it goes to the play.php page. I would like it to display the persons name.. sorry, I meant the get superglobal..so the form has already ben used. do I really have to use a session? If so ill just do it quickly now.. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 24, 2006 Share Posted May 24, 2006 The two ways to pass data around between a lot of pages are either through the querystring (get) or sessions. That's really the only way to do it, even if you use a database or a storage file you still need to pass an ID around through either the querystring or a session.Or you could make every single link a form that submits the stuff through post, but that might be a pain. Most of the time when you pass login info, you do it through the session. Link to comment Share on other sites More sharing options...
reportingsjr Posted May 25, 2006 Author Share Posted May 25, 2006 How does this forum do that? Like in the corner it says your name.. is that by sessions? Link to comment Share on other sites More sharing options...
Jack McKalling Posted May 25, 2006 Share Posted May 25, 2006 Yes it is :) Link to comment Share on other sites More sharing options...
pulpfiction Posted May 25, 2006 Share Posted May 25, 2006 To make it easier you can write a short PHP file to display this message and include that file in every other page. and ofcourse it uses sessions. 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