Jump to content

Parsing/Storing (unknown) URL parameters


Nymor

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.