Arthur
Arthur

Reputation: 3

GET variables of parent window to iframe url

I'm trying to pass on the parent url variables to the variables of the iframe url.

For example if the parent url is: http://mywebsite.com/autos-zoeken?sessid=s838c7e5c3be0452fc38f4ffb6f307ed7&code=be3f&whsearch_key=6568

The iframe url needs to become: http://anotherwebsite.com/s838c7e5c3be0452fc38f4ffb6f307ed7/be3f/stock/6568/

The code I'm using now is:

<?php
 $val1 = $_GET[“sessid“];
 $val2 = $_GET[“code“];
 $val3 = $_GET[“whsearch_key“];
 echo "<iframe src='http://anotherwebsite.com/' . $val1 . '/' . $val2 . '/stock/' . $val3 . '/' id='blockrandom' width='1000' height='1200'

scrolling='auto'

frameborder='0'

class='wrapper'>

Your browser doesn't support inline frames.</iframe>";
?>

The result on the website is: http://anotherwebsite.com/' . . '/' . . '/stock/' . . '/' id='blockrandom1' etc

So the variables aren't being put in the right place in the iframe url

What am I doing wrong here?

Upvotes: 0

Views: 1305

Answers (3)

David
David

Reputation: 218847

You're not actually concatenating multiple strings, you're just building a single string. Take a look at a simplified example:

"<iframe src='http://anotherwebsite.com/' . $val1"

That's just one string which happens to have a period between some spaces. In order to use the . concatenation operator you need to terminate the string first:

"<iframe src='http://anotherwebsite.com/'" . $val1

Upvotes: 0

nobody
nobody

Reputation: 1

    echo "<iframe src='http://anotherwebsite.com/$val1/$val2/stock/$val3/' id='blockrandom' width='1000' height='1200' scrolling='auto' frameborder='0' class='wrapper'>Your browser doesn't support inline frames.</iframe>"; ?> 

you don't need to escape your variables

Upvotes: 0

Azrael
Azrael

Reputation: 1094

this should work fine:

echo "<iframe src='http://anotherwebsite.com/$val1/$val2/stock/$val3/' id='blockrandom' width='1000' height='1200' scrolling='auto' frameborder='0' class='wrapper'> Your browser doesn't support inline frames.</iframe>";


the problem is with all your quote's inside your src, it thinks it needs to stop your src after http://anotherwebsite.com/ and you don't need to use "." inbetween because you used doubleqouote on start, you can just use variables inside doublequotes.

Upvotes: 1

Related Questions