weemikey Posted July 23, 2007 Share Posted July 23, 2007 Hey all. I did a search through the forum, but I can't find an answer for this question. I'm working on a site with another developer and he's got this piece of code to call an iframe. <?php echo ($_GET['iframe'] ? $_GET['iframe'] : '/home.php'); ?> The question is: what is the ":" between $_GET['iframe'] and '/home.php'???? Is it concatenating the two? This WAS working but it set "home.php" to show only the passed in frame. What I'm trying to do is take a url sent via an email and bring the user straight to a specific "activation" page. So the above code does that, but every time you click "home" on the menu, you go to the activation page instead of home.php. That's not what I want! So I created this little thing because it made more sense to have a test to see if the iframe value is being passed. This ONLY happens during activation, so it's a rare thing. <?php if (isset($_GET['iframe'])){ $iframe = $_GET['iframe']; echo $iframe; echo "<iframe src=\'".$iframe."'\" name=\"contentFrame\" id=\"contentFrame\" frameborder=\"0\" hspace=\"0\" vspace=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"auto\" allowtransparency=\"yes\"></iframe>"; } else { echo "<iframe src=\"home.php\" name=\"contentFrame\" id=\"contentFrame\" frameborder=\"0\" hspace=\"0\" vspace=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"auto\" allowtransparency=\"yes\"></iframe>"; } ?> I echo out the $iframe value and it's correct, but I get an error 404 saying the page can't be found. I don't do html and all that, so I'm a bit lost. Any help? It works fine if I don't pass in the iframe value. I do LOVE this place! Thanks, Mikey Quote Link to comment Share on other sites More sharing options...
per1os Posted July 23, 2007 Share Posted July 23, 2007 <?php echo ($_GET['iframe'] ? $_GET['iframe'] : '/home.php'); ?> The ? and : is caled the ternary operator. It is just a shortened if else. If $_GET['iframe'] is true than echo $_GET['iframe'] else echo '/home.php' EDIT::: The second portion the issue is: "<iframe src=\'".$iframe."'\" Should be "<iframe src='".$iframe."' Single quotes do not need escaped when inside double quotes and you cannot mix and match meaning a single quote must be closed by a single quote and not a double. Quote Link to comment Share on other sites More sharing options...
weemikey Posted July 23, 2007 Author Share Posted July 23, 2007 THANK YOU THANK YOU THANK YOU. Hopefully some of this info will stay with me as I learn.... works like hot damn. 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.