Nymor Posted October 28, 2009 Share Posted October 28, 2009 Hi, This is probably a really simple question but hopefully someone will be able to help a php numpty out. I have a php page which has an embedded iframe containing another php file. The hosting webmaster maintains the outer wrapper page and I develop the iframed one. The outer wrapper page may be called with some parameters and sometimes may not - so www.mysite.com/wrapper.php or www.mysite.com/wrapper.php?x=something At the moment I don't know what the parameters (x, y, z etc) are going to be and even if I did they might change over time. What I want to achieve is that the web hosts just add something to their php so that whatever is there is saved in the Session and then I can query the Session to work out what (if any) parameters the wrapper was called with. If I then add new parameters the web hosts wouldn't have to change their code as all params are just stored already (preferrably as an array). Sorry if this has already been covered many times (as I'm sure it has) but I couldn't find it - so any help would be greatly appreciated. Thanks in advance Kindest regards Nymor Quote Link to comment https://forums.phpfreaks.com/topic/179388-parsingstoring-unknown-url-parameters/ Share on other sites More sharing options...
SchweppesAle Posted October 28, 2009 Share Posted October 28, 2009 inside wrapper.php: $blah = $_GET['x'] if(isset($blah)) { //do something } Quote Link to comment https://forums.phpfreaks.com/topic/179388-parsingstoring-unknown-url-parameters/#findComment-946546 Share on other sites More sharing options...
eugene2009 Posted October 28, 2009 Share Posted October 28, 2009 May I see an example of your code? Quote Link to comment https://forums.phpfreaks.com/topic/179388-parsingstoring-unknown-url-parameters/#findComment-946549 Share on other sites More sharing options...
Nymor Posted October 28, 2009 Author Share Posted October 28, 2009 Hi, Thanks. However that's one of the things I've tried but the problem is I don't know what the parameters are going to be - and even if I did they may change over time and I want to be able to change them without the webhosts having to change the wrapper code. Something along the lines of... $_SESSION['urlparams'] = something here to store any params in a urlparams array; ... then from my php (inside an iframe within the wrapper) I can query $_SESSION.urlparams array to work out how I should initialise my code. Nymor Quote Link to comment https://forums.phpfreaks.com/topic/179388-parsingstoring-unknown-url-parameters/#findComment-946550 Share on other sites More sharing options...
Alex Posted October 28, 2009 Share Posted October 28, 2009 If you're not sure what parameters are in your query string you can loop through the $_GET super-global to see. eg. foreach($_GET as $key => $var) { echo "$key => $var"; } Quote Link to comment https://forums.phpfreaks.com/topic/179388-parsingstoring-unknown-url-parameters/#findComment-946551 Share on other sites More sharing options...
Nymor Posted October 28, 2009 Author Share Posted October 28, 2009 Thanks - the $_GET in the wrapper page certainly seems to be the way to go. I have an added mini-complication in that my iframed page is really an html page named .php so I can include a quick test to see whether a user is logged in or not (again this is a session variable). For various reasons I don't want this to be fully php at the moment so what I'm doing is... In the wrapper simply :- $_SESSION['urlparams'] = $_GET; In my iframed html/js (pretending to be php) file:- var has_initParams = 0;<?if(count($_SESSION['urlparams'])>0){?>has_initParams=1;<?} else {?>has_initParams=0;<?}?> Then as part of my initialisation if has_initParams =1 I'll go and get them - if not I don't need to look for them. Inside that call I'll check that the params are allowed/valid and branch my javascript based on the results of that. It seems to work ok - hope I'm not making any potentially horrendous mistakes. (My intention one day will be to convert my pretend php page into a fully fledged one but for now I need it as it is). Thanks again for the pointers. Regards Nymor Quote Link to comment https://forums.phpfreaks.com/topic/179388-parsingstoring-unknown-url-parameters/#findComment-946611 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.