2

I have a php webpage and inside an iframe. ex:

url of the php page http://www.ex.com/index.php?one=anumber

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <iframe id="34" class="ddd" src="two.php"></iframe> </body> </html> 

so what php code to pun in two.php to get the variable one from the parent url?

2
  • i think if you are using any varible in one.php then it will be directly accessible in two.php because the page is completely loading in one.php no matter you are using iframe or include. lets try Commented Feb 10, 2013 at 16:13
  • the variable one is not used (called) in one.php code Commented Feb 10, 2013 at 23:20

2 Answers 2

2

Simplest would be to send the complete query string to two.php, like so

<iframe id="34" class="ddd" src="two.php?<?=$_SERVER['QUERY_STRING']?>"></iframe> 
Sign up to request clarification or add additional context in comments.

1 Comment

I can't do that, I know that your method works but I need some code to use in the two.php page, I can't alter the iframe src. Please note that the two.php is on the same domain as the one.php, I said that because I show a lot of questions asking is the iframe src is on the same domain.
0

got it...so

this is what I did, I'm noob at php but it works

I created 3 php files and this is what code they have

index.php is the same

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <iframe id="34" class="ddd" src="two.php"></iframe> </body> </html> 

in two.php is

<?php //Getting the parent window parameters $getURLVar = str_replace("?","",strrchr($_SERVER['HTTP_REFERER'],"?")); // refreshing the iframe with the variables at the end header("Location: 3.php?$getURLVar"); ?> 

in 3.php is

<?php $pageis888 = $_GET["one"]; ?> 

I know there is a better solution, but this works too :P

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.