Jump to content

[SOLVED] QUICK question on iframes


weemikey

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/61436-solved-quick-question-on-iframes/
Share on other sites

<?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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.