1

I want to check using php if the current page is called by an iframe and not directly in the browser.

It's a page that gets some $_POST parameters while the sending form's target is an iframe, so the page will display in an iframe.

I want to check that using PHP, How?

Thanks.

medk
  • 8,713
  • 18
  • 54
  • 77

2 Answers2

3

You can't. PHP runs serverside. It is for all intents and purposes the same thing as the webserver -- it sees HTTP requests and returns responses. An iframe is a clientside mechanism implemented by the browser that simply allows you to display 2 or more html pages (the response payload).

gview
  • 14,128
  • 3
  • 41
  • 48
2

You can use the SERVER HTTP_REFERER

$_SERVER['HTTP_REFERER'];
Book Of Zeus
  • 48,853
  • 18
  • 173
  • 169
  • 1
    recommendation: if you submit the iframe window you should save the referrer in the form as a hidden field. This will pass the original referrer (the one who called the iframe at first). – Book Of Zeus Aug 26 '11 at 03:37