Passing a parameter/variable between pages
Posted: Fri Nov 12, 2010 3:12 pm
This is probably elementary, but here goes. I need to pass the same variable between a couple forms, and am not sure of the best way to do this using PHP. Example:
page1.php has a button that takes you to the next page. Using an <a href="...", the URL includes the id, and looks something like this: "www.mydomain.com/page2.php?my_id=2". This is working perfectly.
page2.php uses a $_GET['my_id'] to get that number 2, and does whatever it needs to do with the information. That much is also working perfectly.
page2.php also includes yet another button that will pass yet another variable to page3.php. something like: "www.mydomain.com/page3.php?another_id=4"
What I need is to have 'my_id' (from page1.php, used in page2.php) available in page3.php. I can use the $_GET to access 'another_id', but I can't seem to figure out how to also have access to 'my_id' originally generated from the page1.php.
Is using the superglobals the way to go here, and if so, can I get a sample line of code to show how to keep 'my_id' available? Or is there another technique I am overlooking?
thanks much,
tc
page1.php has a button that takes you to the next page. Using an <a href="...", the URL includes the id, and looks something like this: "www.mydomain.com/page2.php?my_id=2". This is working perfectly.
page2.php uses a $_GET['my_id'] to get that number 2, and does whatever it needs to do with the information. That much is also working perfectly.
page2.php also includes yet another button that will pass yet another variable to page3.php. something like: "www.mydomain.com/page3.php?another_id=4"
What I need is to have 'my_id' (from page1.php, used in page2.php) available in page3.php. I can use the $_GET to access 'another_id', but I can't seem to figure out how to also have access to 'my_id' originally generated from the page1.php.
Is using the superglobals the way to go here, and if so, can I get a sample line of code to show how to keep 'my_id' available? Or is there another technique I am overlooking?
thanks much,
tc