Jump to content

[SOLVED] iframe url variable


pewee2000

Recommended Posts

Hi,

 

I have an iframe in which I want to load an external page into. I only want to input the first half of the url in the coding. The second part of the url I want to input into the address bar i.e.

address bar: www.mysite.com/myfolder/myiframepage.php?token=6IDKJH1B&source=WR (in red is the part of the url I want to pass to add on to the coded url)

coded url: www.externalsite.com/externalfolder/externalfile.php?

 

So it would end up getting the iframe page from www.externalsite.com/externalfolder/externalfile.php?token=6IDKJH1B&source=WR

 

The whole point of this is to be able to make the  content of the iframe changeable.

 

Hope this makes sense.

 

Thanks in advance.

Link to comment
Share on other sites

Unfortunately I have no understanding of php other than what it is capable of. Im not a student or anything looking to become a php expert I just need a quick bit of help with this. I can quite easily do this in flash - combining url variable string with a set url, but seeing as I cant do anything with that result I need to use php. I understand your trying to get people to learn through their own mistakes, but anything I put would be a mistake as I'm not sure how to start.

 

I just found this below and tried to adapt it, but I don't understand it enough to modify it correctly. Any ideas?

 

 

<body>

 

<iframe>

<?php

 

if (!isset($_GET['token']) {

$token = "about";

} else {

$token = $_GET['token'];

}

 

include ("http://www.mysite.com/player.pl?".$token.);

 

?>

</iframe>

 

</body>

Link to comment
Share on other sites

I have made some progress...

 

<body>

<?php

 

$token = $_GET['token'];

$source = $_GET['source'];

 

 

$playerpage = "http://www.mywebsite/myfolder/player.pl?token=".$token."&source=".$source.".php";

 

include $playerpage;

?>

</body>

 

Now if I change include to echo I see the full string that I want to display as content. As soon as I change it to include it throws up lots of errors. The other thing is that I don't know how to get it to work within a iframe (i'm guessing this is simple).

Link to comment
Share on other sites

Warning: include() [function.include]: URL file-access is disabled in the server configuration in \\NAS35ENT\domains\m\mywebsite.com\user\htdocs\video-test\index2.php on line 21

 

Warning: include(http://www.externalwebsite/myfolder/player.pl?token=61DKJH1B&source=WR.php) [function.include]: failed to open stream: no suitable wrapper could be found in \\NAS35ENT\domains\m\mywebsite.com\user\htdocs\video-test\index2.php on line 21

 

Warning: include() [function.include]: Failed opening http://www.externalwebsite/myfolder/player.pl?token=61DKJH1B&source=WR.php' for inclusion (include_path='.;C:\php5\pear') in \\NAS35ENT\domains\m\mywebsite.com\user\htdocs\video-test\index2.php on line 21

 

 

I have masked the sites as mywebsite and externalwebsite

Link to comment
Share on other sites

you are going to have to use relative file paths, as more than likely your allow_url_fopen setting is set to off (this setting tells whether or not full URLS are allows)

 

This is set to off by default because of a security risk. You can read more about it here: http://www.learnphponline.com/errors/url-file-access-is-disabled-in-the-server-configuration

 

Depending on where the file that includes you other file is, you should be able to just put the relative path. IE

 

include("myfolder/to/my/file.ext")

Link to comment
Share on other sites

The small problem I have is that I can't use a local path. The only thing I have managed to come up with is:

 

<iframe

 

<?php

$token = $_GET['token'];

$source = $_GET['source'];

 

 

$playerpage = "http://www.externalwebsite/player.pl?token=".$token."&source=".$source.".php";

?>

 

scrolling=auto id=rf src="<?php

 

print $playerpage ?>" frameborder=0 allowtransparency=true style="width:100%;height:100%"></iframe>

 

 

This comes up with a blank iframe, but the idea is there. I'm thinking of trying to put the $playerpage into the src of the iframe instead of using  include (which only allows for local files)

 

Any ideas?

Link to comment
Share on other sites

Silly me!! it works!! Finally.

 

I had got the token information wrong in the address bar from the external site. So what I had posted last works with external sites in an iframe. It doesn't work with the include method.

 

Thanks people for all your efforts in helping me achieve this.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.