prcollin Posted June 3, 2008 Share Posted June 3, 2008 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 Quote Link to comment Share on other sites More sharing options...
jvrothjr Posted June 3, 2008 Share Posted June 3, 2008 you want your page to be a proxy? Quote Link to comment Share on other sites More sharing options...
prcollin Posted June 3, 2008 Author Share Posted June 3, 2008 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? Quote Link to comment Share on other sites More sharing options...
ringworld Posted June 3, 2008 Share Posted June 3, 2008 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. Quote Link to comment Share on other sites More sharing options...
prcollin Posted June 3, 2008 Author Share Posted June 3, 2008 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 Quote Link to comment Share on other sites More sharing options...
ringworld Posted June 3, 2008 Share Posted June 3, 2008 you have to hit enter, it is possible to put a button in though Quote Link to comment Share on other sites More sharing options...
ringworld Posted June 3, 2008 Share Posted June 3, 2008 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> Quote Link to comment Share on other sites More sharing options...
kbh43dz_u Posted June 3, 2008 Share Posted June 3, 2008 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.) Quote Link to comment Share on other sites More sharing options...
ringworld Posted June 3, 2008 Share Posted June 3, 2008 I was thinking the same thing but the js way may bee more complicated, I actually did this the javascript way once and it was glitchy. If I come across the code I will post it here. Quote Link to comment Share on other sites More sharing options...
blufish Posted June 3, 2008 Share Posted June 3, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.