JJBlaha Posted March 1, 2007 Share Posted March 1, 2007 This is my issue, simplified down. http://sub.domain.com/page1.php <?php include('http://www.domain.com/main/page2.php'); ?> http://www.domain.com/main/page2.php <?php echo "Test is "; echo $_GET['test']; ?> http://sub.domain.com/page1.php?test=test returns Test is And if i change page1.php to http://sub.domain.com/page1.php <?php echo "Test is "; echo $_GET['test']; ?> http://sub.domain.com/page1.php?test=test returns Test is test What is going on? Link to comment https://forums.phpfreaks.com/topic/40778-problem-with-_get-vars-when-including-a-file-across-subdomains/ Share on other sites More sharing options...
btherl Posted March 2, 2007 Share Posted March 2, 2007 You can't use include() for that. You should use readfile() instead. To preserve the $_GET variables, you will need to explicitly add them to the readfile() call, like this: readfile('http://www.domain.com/main/page2.php?test=test'); As for doing that in practice, you can hardcode it if you only expect a fixed set of $_GET variables. Otherwise you can use a foreach loop to add each $_GET variable. Link to comment https://forums.phpfreaks.com/topic/40778-problem-with-_get-vars-when-including-a-file-across-subdomains/#findComment-197496 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.