Jarid Posted August 6, 2010 Share Posted August 6, 2010 I am using this php code <?php echo $_GET['CiFrame']; ?> to check the url for the variable CiFrame, this allows me to link to a page through my page containing the iframe. Here is my iframe code. <iframe name="CiFrame" width="727" height="805" src="<?php echo $_GET['CiFrame']; ?>" scrolling="auto" frameborder="0"></iframe> The problem is that if the url does not contain a variable the iframe will not open a page. How can i set a default variable if one is not provided? Thank You Quote Link to comment Share on other sites More sharing options...
litebearer Posted August 6, 2010 Share Posted August 6, 2010 psuedo... if isset get var = passed value else var = default value Quote Link to comment Share on other sites More sharing options...
Jarid Posted August 6, 2010 Author Share Posted August 6, 2010 I don't understand how to apply the code you provided. I set $Openme as the var. I still don't understand how to check the url for CiFrame or use a default value if CiFrame is not specified in the url. Here is what i tried next, however it did not work. Any ideas? <?php if (isset ($_GET['CiFrame'])) $Openme = 'CiFrame'; else $Openme = '/NonMembersFeatured.php'; ?> Iframe Code <iframe name="CiFrame" width="727" height="805" src="<?php $Openme ?>" scrolling="auto" frameborder="0"></iframe> Thank You Quote Link to comment Share on other sites More sharing options...
will35010 Posted August 6, 2010 Share Posted August 6, 2010 I don't understand how to apply the code you provided. I set $Openme as the var. I still don't understand how to check the url for CiFrame or use a default value if CiFrame is not specified in the url. Here is what i tried next, however it did not work. Any ideas? <?php if (isset ($_GET['CiFrame'])) $Openme = 'CiFrame'; else $Openme = '/NonMembersFeatured.php'; ?> Iframe Code <iframe name="CiFrame" width="727" height="805" src="<?php $Openme ?>" scrolling="auto" frameborder="0"></iframe> Thank You that should be: <?php if (isset ($_GET['CiFrame'])) $Openme = $_GET['CiFrame']; else $Openme = '/NonMembersFeatured.php'; ?> Quote Link to comment Share on other sites More sharing options...
Jarid Posted August 6, 2010 Author Share Posted August 6, 2010 I put <?php if (isset ($_GET['CiFrame'])) $Openme = $_GET['CiFrame']; else $Openme = '/NonMembersFeatured.php'; ?> In the body right above my iframe code <iframe name="CiFrame" width="727" height="805" src="<?php $Openme ?>" scrolling="auto" frameborder="0"></iframe> I uploaded the page to my server and opened it in my browser. The iframe did not open /NonMembersFeatured.php and when i right clicked and went to source code my iframe showed src="". Why is this not working? Quote Link to comment Share on other sites More sharing options...
hiprakhar Posted August 6, 2010 Share Posted August 6, 2010 I put <?php if (isset ($_GET['CiFrame'])) $Openme = $_GET['CiFrame']; else $Openme = '/NonMembersFeatured.php'; ?> In the body right above my iframe code <iframe name="CiFrame" width="727" height="805" src="<?php $Openme ?>" scrolling="auto" frameborder="0"></iframe> I uploaded the page to my server and opened it in my browser. The iframe did not open /NonMembersFeatured.php and when i right clicked and went to source code my iframe showed src="". Why is this not working? Try: <iframe name="CiFrame" width="727" height="805" src="<?php echo isset ($_GET['CiFrame'])?$_GET['CiFrame']:'/NonMembersFeatured.php' ?>" scrolling="auto" frameborder="0"></iframe> do tell if that worked Quote Link to comment Share on other sites More sharing options...
Jarid Posted August 6, 2010 Author Share Posted August 6, 2010 Thanks for the help hiprakhar your solution worked, now i just have to adapt it for a few more pages. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.