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