Jump to content

iFrame Question


prcollin

Recommended Posts

I have this code

 

<html>
<form action="post" name="iframe">
Enter a web address:<input type="text" name="text1">
<?php
$text1 ='text1';
?>
<iframe
src ="$text1"
width="100%">
</iframe>

</html>

 

basically what i want is for the user to type in a web address and the iframe src function reads it and loads that page according to the input by the user after clicking submit.  My friend derived this code and I dont know what to tell him cause i have never worked with iframes before

Link to comment
https://forums.phpfreaks.com/topic/108473-iframe-question/
Share on other sites

you want your page to be a proxy?

 

 

 

kinda i just want people to be able to type in a text box press submit then the iframe src goes to the web address the type in the text box.  I just dont know how to do this with iframe

 

something in the mindset of

 

<form action="      " name="form">

Enter web address: <input name="webaddress type="text"> <input type="submit" name="go">

 

then I dont know what to do next to get a php script to post the webadress text into the iframe src="  "

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/108473-iframe-question/#findComment-556193
Share on other sites

This code is called iframe.php

<html>
<body>
<form action="iframe.php" method="post">
Enter a web address:<input type="text" name="url">
<?php

$url = $_POST['url'];

echo "<iframe src='http://";
echo $url;
echo "'></iframe>";

?>
</body>
</html>

That works, I just made it and tested it myself, I am proud of myself lol ;), I have been wanting to do the same for a long time. You may notice that when you run the page the iframe show up with page cannot be found. That is because I added http:// because when you run the script locally if you put www.google.com in it would look for it on your site. So you have to put http://www.google.com in.

Link to comment
https://forums.phpfreaks.com/topic/108473-iframe-question/#findComment-556195
Share on other sites

This code is called iframe.php

<html>
<body>
<form action="iframe.php" method="post">
Enter a web address:<input type="text" name="url">
<?php

$url = $_POST['url'];

echo "<iframe src='http://";
echo $url;
echo "'></iframe>";

?>
</body>
</html>

That works, I just made it and tested it myself, I am proud of myself lol ;), I have been wanting to do the same for a long time. You may notice that when you run the page the iframe show up with page cannot be found. That is because I added http:// because when you run the script locally if you put www.google.com in it would look for it on your site. So you have to put http://www.google.com in.

 

i just get a text box and a blank iframe no way of submitting the entered url

 

Link to comment
https://forums.phpfreaks.com/topic/108473-iframe-question/#findComment-556199
Share on other sites

Okay, here is the final code with a submit button and some things to make page look better.

<html>
<head>
<style>
body{
padding: 0px;
margin: 0px;
}
</style>
</head>
<body>
<form action="iframe.php" method="post">
Enter a web address:<input type="text" name="url">
<input type="submit" value="Go />
<br />
<?php

$url = $_POST['url'];

echo "<iframe width='100%' height='500px' frameborder='0' src='http://";
echo $url;
echo "'></iframe>";

?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/108473-iframe-question/#findComment-556227
Share on other sites

This will NOT be a kind of proxy!! because iframe source is loaded and included from the visitors PC - not from the server. And because of that it would be much better to do it with javascript, than you don't have traffic/requests all the time (and the visitor has anyway.)

Link to comment
https://forums.phpfreaks.com/topic/108473-iframe-question/#findComment-556289
Share on other sites

the JS might be something like:

<html>
<head>
<script type="text/javascript">
bob.src = document.wow.whereto.value
</script>
</head>
<body>
<form name="wow">
<input type=text name="whereto"><p onclick="gotosite()">Go Now!</p>
</form>
<iframe name="bob">
</body>
</html>

 

Note I just did this really quickly you would have to clean it up.  This isn't really a php question.

 

 

Link to comment
https://forums.phpfreaks.com/topic/108473-iframe-question/#findComment-556568
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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