1

I am trying to create a website that displays another website in an iframe.

This is my code:

<html> 
<title>HTML with PHP</title>
<style>
body {
margin: 0px;
}
</style>
<body>
<?php
$page = $_GET['query'];
echo $page;
?>
<iframe align="center" width="100%" height="100%" src="<?=$page;?>" frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>
</body>
</html>

When I open the php file off of my website (using a url website.com/file.php?query=https://www.google.com, and look in the inspector, I can see the page that the iframe loaded, but it just shows up as a blank page, not the . I have it up at http://www.test.fire-light.tk/web.php?query=url (replace url with any valid url). I am not sure why it shows the blank page.

3
  • 1
    what happens when you hardcode the iframe's src? does it load or is it still white? Commented Nov 29, 2013 at 0:25
  • Can you try $page = $_GET['q']; instead of that thing you're trying with explode? Commented Nov 29, 2013 at 0:26
  • When I hardcode the iframe's src, it is still white. When I use $page = $_GET['q']; it still shows the correct url. Commented Nov 29, 2013 at 3:05

3 Answers 3

5

Using Iframe you can call PHP file in HTML file . And write your PHP code in test.php Iframe code <iframe src="test.php"></iframe>

Sign up to request clarification or add additional context in comments.

Comments

3

I think this:

<iframe align="center" width="100%" height="100%" src="<?=$page;?>" 
  frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>

should be changed into:

<iframe align="center" width="100%" height="100%" src="<? echo $page; ?>"  
  frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>

Comments

-1

Try this instead:

<html> 
<title>HTML with PHP</title>
<style>
body {
margin: 0px;
}
</style>
<body>
<?php
$url = $_SERVER['REQUEST_URI'];
$parts = explode('?=', $url);
$page = $parts[1];
echo '<iframe align="center" width="100%" height="100%" src="$page" frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>';
?>
</body>
</html>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.