emma225 Posted December 3, 2008 Share Posted December 3, 2008 This should be so simple but is causing me a lot of grief. I need a web form with a text box where user woould enter url, then click go button, and url would open in new window. This was as far as I got <?PHP $urlToGoTo = @$_POST["url"]; if(!empty($urlToGoTo)){ header($urlToGoTo); } ?> Any advice would be appreciated Cheers ;) Link to comment https://forums.phpfreaks.com/topic/135433-solved-enter-url-then-click-to-open-in-new-window/ Share on other sites More sharing options...
DarkWater Posted December 3, 2008 Share Posted December 3, 2008 You should just do this in Javascript. <form name="redirect" onsubmit="window.location = document.getElementById('redirect_link').value; return false;" action="" method=""> <input id="redirect_link" type="text" /> <input type="submit" value="Go!" /> </form> Link to comment https://forums.phpfreaks.com/topic/135433-solved-enter-url-then-click-to-open-in-new-window/#findComment-705494 Share on other sites More sharing options...
gevans Posted December 3, 2008 Share Posted December 3, 2008 you know you could just do this with javascript <input type="text" value="" id="href" /> <input type="submit" value="go" onlick="window.location=getElementById('href').value;" /> not tested, but you get the idea Link to comment https://forums.phpfreaks.com/topic/135433-solved-enter-url-then-click-to-open-in-new-window/#findComment-705501 Share on other sites More sharing options...
gevans Posted December 3, 2008 Share Posted December 3, 2008 got beaten to it!! Link to comment https://forums.phpfreaks.com/topic/135433-solved-enter-url-then-click-to-open-in-new-window/#findComment-705502 Share on other sites More sharing options...
emma225 Posted December 3, 2008 Author Share Posted December 3, 2008 Thanks a million for you suggestions. I'm nearly there I think. Still having a problem though, when I click 'go' it takes me to the place where the file is saved C:\wamp\www\www.google.com or the same on the server Any ideas?? Cheers Link to comment https://forums.phpfreaks.com/topic/135433-solved-enter-url-then-click-to-open-in-new-window/#findComment-705544 Share on other sites More sharing options...
gevans Posted December 3, 2008 Share Posted December 3, 2008 trying putting http:// behind it you could do a little check in javascript to make sure that is in place Link to comment https://forums.phpfreaks.com/topic/135433-solved-enter-url-then-click-to-open-in-new-window/#findComment-705553 Share on other sites More sharing options...
emma225 Posted December 4, 2008 Author Share Posted December 4, 2008 Sorted. Brilliant, been at that for days. Thanks ;D Link to comment https://forums.phpfreaks.com/topic/135433-solved-enter-url-then-click-to-open-in-new-window/#findComment-705570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.