pistonhead Posted March 16, 2010 Share Posted March 16, 2010 Hi I was wondering- how can I transfer fixed variables (which are declared in the code, no input from user) between pages, without using the URL (preferably using buttons)? Any help would be greatly appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/195488-transferring-variables-between-pages/ Share on other sites More sharing options...
ksugihara Posted March 16, 2010 Share Posted March 16, 2010 $_POST Quote Link to comment https://forums.phpfreaks.com/topic/195488-transferring-variables-between-pages/#findComment-1027260 Share on other sites More sharing options...
pistonhead Posted March 16, 2010 Author Share Posted March 16, 2010 $_POST That means I'd have to include a form, but the variables have nothing to do with the user. I require no input from them. Quote Link to comment https://forums.phpfreaks.com/topic/195488-transferring-variables-between-pages/#findComment-1027264 Share on other sites More sharing options...
ksugihara Posted March 16, 2010 Share Posted March 16, 2010 i assume there will be some clicking somewhere on the page, as you said you'd like to pass variables based on a user clicking a button. <form name="passing vars" method="post"> <input type="hidden" value="variable" /> <input type="hidden" value="variable2" /> <input type="button" value="Continue on without filling out any of the HIDDEN fields cause im pr0" /> </form> You are correct. It requires a form. but not one that the user can fill out. Quote Link to comment https://forums.phpfreaks.com/topic/195488-transferring-variables-between-pages/#findComment-1027268 Share on other sites More sharing options...
5kyy8lu3 Posted March 16, 2010 Share Posted March 16, 2010 Hi I was wondering- how can I transfer fixed variables (which are declared in the code, no input from user) between pages, without using the URL (preferably using buttons)? Any help would be greatly appreciated. Thanks use session variables. just makes sure you have session_start(); at the top of each page else the session variables won't work Page1: <?php session_start(); $_SESSION['AnswerToLife'] = 42; ?> Page2: <?php session_start(); echo $_SESSION['AnswerToLife']; //it would output '42' ?> Quote Link to comment https://forums.phpfreaks.com/topic/195488-transferring-variables-between-pages/#findComment-1027279 Share on other sites More sharing options...
pistonhead Posted March 16, 2010 Author Share Posted March 16, 2010 Is there any way I could transfer the variables using clickable pictures? i.e: <a href="diagram.php"><img align="left"border="0" src="globe/200px-Europe_(orthographic_projection).svg.png" width="150" alt="Europe" height="150" alt="Europe"/></a> Quote Link to comment https://forums.phpfreaks.com/topic/195488-transferring-variables-between-pages/#findComment-1027295 Share on other sites More sharing options...
5kyy8lu3 Posted March 16, 2010 Share Posted March 16, 2010 Is there any way I could transfer the variables using clickable pictures? i.e: <a href="diagram.php"><img align="left"border="0" src="globe/200px-Europe_(orthographic_projection).svg.png" width="150" alt="Europe" height="150" alt="Europe"/></a> only way I can think of doing it from clickable pictures is to do it through a url variable, such as <a href="diagram.php?picture=Europe"><img></a> Quote Link to comment https://forums.phpfreaks.com/topic/195488-transferring-variables-between-pages/#findComment-1027301 Share on other sites More sharing options...
pistonhead Posted March 16, 2010 Author Share Posted March 16, 2010 Is there any way I could transfer the variables using clickable pictures? i.e: <a href="diagram.php"><img align="left"border="0" src="globe/200px-Europe_(orthographic_projection).svg.png" width="150" alt="Europe" height="150" alt="Europe"/></a> only way I can think of doing it from clickable pictures is to do it through a url variable, such as <a href="diagram.php?picture=Europe"><img></a> Aah, I'm using a specific API key for the linked page. Guess I could send the variables via the URL, and have a conditional statement within the linked page, which selects a certain API key based on the variables passed through. Thanks a lot for your help. Quote Link to comment https://forums.phpfreaks.com/topic/195488-transferring-variables-between-pages/#findComment-1027307 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.