Can I pass a URL variable in an IFrame using PHP?

I have not used PHP before (or at all), and I have the following code:

<?php
$val = $_GET['ID'];
echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid='$val'    width='100%' scrolling='vertical'></iframe>";
?>

I think that it should be good to take the URL variable and pass it to the iframe url ... my problem is that when I click on the page, it means instead:

http://sitename.com/whats-on?ID=2

his

http://sitename.com/whats-on/?ID=2

I don’t know where is the slash before /? The identifier comes, but I believe this is causing my problem - iframe displays a message not found by the page.

Any advice is appreciated.

thank

Simon

+5
source share
3 answers

iFrames just take the url - and the parameters can be embedded in the urls just fine.

The problem, if I clearly understand the question, is that you are mixing your quotes:

 echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid='$val'
        width='100%' scrolling='vertical'></iframe>";

will be displayed as

 <iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=' 21254545' 
  width='100%' scrolling='vertical'></iframe>

21254545 iframe URL.

, URL-, - :

echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=$val' width='100%' scrolling='vertical'></iframe>";

.

+6
  • http:// sitename.com.au/
  • memberid = '$ val' memberid = $val ' [ $val]
<?php
   $val = $_GET['ID'];
   echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=$val' width='100%' scrolling='vertical'></iframe>";
?>
0

It seems that

echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=$val' width='100%' scrolling='vertical'></iframe>";

does not work any more. You must add such a variable

 echo "<iframe src='sitename.com.au/directory/app/pagename.cfm?memberid=".$val."' width='100%' scrolling='vertical'></iframe>";

Since anwser has been since 2012 ... maybe PHP fixed it so that it can be used now.

0
source

All Articles