i want the iframe to show only if

I have an iframe, which I have embedded onto a production site. I am still working on it here is the iframe the table with results

The problem is that I don't want any one to see it, So i am wondering is there any way to add something to the link look's like.

http://www.chessbook.net/ZULUTESTINGSITE/index.php?option=com_chess&id=350**&result** 

That way only when i add the &result it'll show the iframe below is the iframe code on the page

<div>
   <iframe src="http://users.hellzoneinc.com/eric258/preview.php" width="50%" 
           height="300" scrolling="auto" frameborder="0" name="results"> 
   </iframe>
</div>

Upvotes: 2

Views: 275

Answers (2)

RiggsFolly
RiggsFolly

Reputation: 94662

Your suggested method should work quite nicely assuming that the script containing this HTML is a .php script and will be passed to the PHP interpreter. If the extension of this file is anything other than .php then of course the PHP script part will not be passed to the interpreter.

All you need to do is this

<?php
if ( isset($_GET['result']) ) :
?>
    <div>
       <iframe src="http://users.hellzoneinc.com/eric258/preview.php" width="50%" 
               height="300" scrolling="auto" frameborder="0" name="results"> 
       </iframe>
    </div>
<?php
endif;
?>

As normal accesses will not have this new &result parameter set in the $_GET array, this iframe should only be placed in the page when you add the extra parameter to the url

Note: All you need to test for is the existance of the &result parameter that you are adding to the original URL as you are not adding any value to it i.e. you are not doing $result="something"

If your HTML is in a file called something.html then of course you could just make a copy of it and call it something_test.html and then you dont have to bother with the parameter or the PHP script addition.

Upvotes: 1

vanurag
vanurag

Reputation: 297

you should do something like below:

 <?php if(isset($_GET['result']) OR $_GET['result'])=='Your_SOME_VALUE'){?>
<div>
<iframe src="http://users.hellzoneinc.com/eric258/preview.php" width="50%" height="300" scrolling="auto" frameborder="0" name="results"> </iframe>
</iframe>
        </div>
 <?php }?>

And your URL should be

http://www.chessbook.net/ZULUTESTINGSITE/index.php?option=com_chess&id=350&result=Your_SOME_VALUE

Upvotes: 1

Related Questions