Adeus Posted December 19, 2007 Share Posted December 19, 2007 Hello, I've encountered an error using the following method to grab a variable from the URL: The actual URL is something like: http://www.something.com/list.php?item=xxx&e=686 My code to grab the variable $e is as follows; if (isset($_POST['e'])) { $_POST['e'] = $e; } Further down the page I use the variable in; echo " <iframe src=\"http://www.othersite.com/items.cfm?client=xxxx&e=$e\"></iframe>"; When I view the source, it does not carry the $e variable down to the iframe link (it just appends "&e=" to the end). I have uploaded this to two testing servers. It works on PHP 4.3.11, but not PHP 4.4. Is there an option in the configuration that would cause this error? Or have I made a rookie mistake somewhere? Link to comment https://forums.phpfreaks.com/topic/82363-solved-problem-_getting-variables-from-url/ Share on other sites More sharing options...
phpSensei Posted December 19, 2007 Share Posted December 19, 2007 try if (isset($_GET['e'])) { $_POST['e'] = $e; } Link to comment https://forums.phpfreaks.com/topic/82363-solved-problem-_getting-variables-from-url/#findComment-418686 Share on other sites More sharing options...
craygo Posted December 19, 2007 Share Posted December 19, 2007 Any variable that shows up in your address bar would be retrieved using the $_GET syntax. Others will be $_POST. If you want you can always use $_REQUEST and that will retrieve either one. Ray Link to comment https://forums.phpfreaks.com/topic/82363-solved-problem-_getting-variables-from-url/#findComment-418690 Share on other sites More sharing options...
Adeus Posted December 19, 2007 Author Share Posted December 19, 2007 Thanks for your quick replies. Unfortunately, it is still not working. I even made a test page with the following code in the <body>; <?php $_GET['e'] = $e; echo "Your variable is $e"; ?> When I follow http://www.something.com/test.php?e=686, it does not display the variable (of course, it just says "Your variable is"). This leads me to believe something is screwey in the configuration. Is there something to toggle to disable $_GET functionality? Thanks Link to comment https://forums.phpfreaks.com/topic/82363-solved-problem-_getting-variables-from-url/#findComment-418763 Share on other sites More sharing options...
phpSensei Posted December 19, 2007 Share Posted December 19, 2007 Your doing it wrong <?php $e = $_GET['e']; echo "Your variable is $e"; ?> Link to comment https://forums.phpfreaks.com/topic/82363-solved-problem-_getting-variables-from-url/#findComment-418767 Share on other sites More sharing options...
Adeus Posted December 19, 2007 Author Share Posted December 19, 2007 D'oh!! Thank you very much, it is now working as intended. Link to comment https://forums.phpfreaks.com/topic/82363-solved-problem-_getting-variables-from-url/#findComment-418774 Share on other sites More sharing options...
phpSensei Posted December 19, 2007 Share Posted December 19, 2007 D'oh!! Thank you very much, it is now working as intended. Which language did you learn lol. np Link to comment https://forums.phpfreaks.com/topic/82363-solved-problem-_getting-variables-from-url/#findComment-418784 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.