Get data from the iFrame URL on each page of the iframe

advertisements

Scenario

I'm using same URL for iFrame source and Website.

The main URL is: https://www.disciplinexgames.com/beta/index

In iFrame it is : < iframe src="https://www.disciplinexgames.com/beta/index?key=YW41y7o0ejxWVVWv7tGOv1eZMdsdew&an=pactpro&[email protected]&web=www.pactpro.net">< /iframe>

Iframe is for our partners who want to offer our service on there own website, in this case http://www.pactpro.net. Main URL is for our own User to browse through the platform.

So the code as in front-end and backend is same for both, in iFrame we just changes the logo, name, background colour, etc , which our partner has provided.

Problem

Problem is that first time when the iFrame loads I'm able to get the below from the URL using $_REQUEST or $_GET. But when user go into other pages within iFrame than $_GET['key'] returns blank, hence it's not able to fetch the data from URL.

key=YW41y7o0ejxWVVWv7tGOv1eZMdsdew
an=pactpro
[email protected]
web=www.pactpro.net

Is it possible to Get the data on every page from the iFrame src as we're getting first time. The iFrame source remains always the same but when it comes to get the Data from iFrame source, it return blank.

I'll really appreciate your your guidance in this.


Regarding my comment, have a look at this function

<?php
function hyperlink($url, Array $persist, Array $source) {
    $variables = array();

    foreach ($persist as $key)
    {
        if (isset($source[$key]))
        {
            $variables[$key] = $source[$key];
        }       

    }   

    return $url.'?'.http_build_query($variables);
}

On your templates, everytime you want to output an URL you must do it like

<?php echo hyperlink('http://example.com', $iframe_vars, $_GET); ?>

Where $iframe_vars must be an array with the name of the variables you use with iframes and must be persisted across requests

<?php
$iframe_vars = array('key','an','uname','web');