Abude
Abude

Reputation: 2162

set a php variable only in the iframe

so i have a code like this:

if ($var == null || 'NULL'){
echo "<h1>something</h1>";
echo "<div id='footer'><b>something</b><br/><br/><br/></div>";
echo "<b>something</b>";}
    else {}

so, on my main page the value var == null and that's great because i want those linse to be displayed in that page, but if i have an iframe somewhere else and i want to set this variable to 1 like $var = 1 so it doesn't show in the iframe but instead will show on the main page because there the value is null, how can i do this?

Upvotes: 0

Views: 392

Answers (1)

wroniasty
wroniasty

Reputation: 8052

You can't detect an iframe on the server-side, but you can pass an additional parameter to your script when embedding an iframe on your page:

<iframe src="script.php?iframe=1"></iframe>

And then check for the value of $_GET['iframe'].

Upvotes: 4

Related Questions