PHP, HTTP_REFERER not working on iframe?

10,076

In either case you're seeing the output of index.php. Here's why:

Scenario 1)

When you hit index.php from the link in test.php, it loads index.php (with test.php as the HTTP_REFERER).

Scenario 2)

When you hit iframe.php from the link in test.php, it loads iframe.php which internally loads index.php in the <iframe> tag (with iframe.php as the HTTP_REFERER).

Share:
10,076
mysqllearner
Author by

mysqllearner

Updated on June 04, 2022

Comments

  • mysqllearner
    mysqllearner almost 2 years

    Okay, here is my situation.

    I have a page, index.php, which is the mainsite (flash site)

    I have another page called iframe.php which contain iframe of index.php

    Another page, test.php. Inside have 2 links, 1st link is directly to index.php, another link is to iframe.php

    I tested:

    • I click the 1st link, when i trace/echo the HTTP_REFERER, it displays "test.php", but

    • I click on 2nd link, when i trace/echo the HTTP_REFERER, it displays "iframe.php".

    Why it display "iframe.php"? Is HTTP_REFERER does not work on iframe??

    Is there anyway to get the "test.php" when i click on second link?

    Source code for :index.php

    <html>
    <head> // Some headers information
    <script type="text/javascript" src="js/swfobject.js"></script>
    <script type="text/javascript">
    var flashvars = {};
        <?php
    if(!empty($_SERVER['HTTP_REFERER'])){
    ?>
        flashvars.link       =  '<?php echo $_SERVER['HTTP_REFERER']; ?>';
    <?php
    }
    ?>
    var params = {};
    var attributes = {};
    swfobject.embedSWF("main.swf, "content", "100%", "100%", "9", "expressInstall.swf", flashvars, params, attributes);
    </script>
    </head>
    <body>
        <div id="content">
        <a href="http://www.adobe.com/go/getflashplayer">
                <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
            </a>
        </div>
    </body>
    </html>
    

    Source code for iframe.php

    <html> headers tag
    ...
    <body>
    <center><iframe src="index.php" mce_src="index.php" frameborder="0" height="500" scrolling="no" width="500"></iframe></center>
    </body>
    </html>
    

    Source code for test.php:

    ....
    <a href="iframe.php" target="_blank">This is Iframe</a> <br><br>
    ....
    <a href="index.php" target="_blank">This is normal link</a> <br><br>