scottybwoy Posted January 11, 2008 Share Posted January 11, 2008 Simple question, How do I send a string to the url. Or just redirect to another page, withou having to install http pecl Quote Link to comment https://forums.phpfreaks.com/topic/85540-url-redirect/ Share on other sites More sharing options...
twostars Posted January 11, 2008 Share Posted January 11, 2008 Simple question, How do I send a string to the url. Or just redirect to another page, withou having to install http pecl 1: HTML meta refresh tag <meta http-equiv="refresh" content="seconds;url=url here"> 2: Javascript header change script <script type="text/javascript"> <!-- window.location = "URL here" //--> </script> 3: PHP's header function. header("Location: $url"); Quote Link to comment https://forums.phpfreaks.com/topic/85540-url-redirect/#findComment-436517 Share on other sites More sharing options...
scottybwoy Posted January 18, 2008 Author Share Posted January 18, 2008 Can this be done without javascript, as I already have it working with javascript, but want to replace it with pure php 4 so that users without java can use the function. I'm using a select menu to jump to another page, by the way. Quote Link to comment https://forums.phpfreaks.com/topic/85540-url-redirect/#findComment-442588 Share on other sites More sharing options...
adam291086 Posted January 18, 2008 Share Posted January 18, 2008 Can you give an example of what you are wanting to achieve Quote Link to comment https://forums.phpfreaks.com/topic/85540-url-redirect/#findComment-442589 Share on other sites More sharing options...
tinker Posted January 18, 2008 Share Posted January 18, 2008 As twostars states: header("Location: $url"); Just make sure you don't output anything else before this function is called! See this, and it's php4 compliant... Quote Link to comment https://forums.phpfreaks.com/topic/85540-url-redirect/#findComment-442720 Share on other sites More sharing options...
Daniel0 Posted January 18, 2008 Share Posted January 18, 2008 Can this be done without javascript, as I already have it working with javascript, but want to replace it with pure php 4 so that users without java can use the function. I'm using a select menu to jump to another page, by the way. Just for the record, Javascript is not the same as Java. They are two entirely different languages. Seeing as you are using a select menu there is no other way than using Javascript. This cannot be accomplished with PHP code. Quote Link to comment https://forums.phpfreaks.com/topic/85540-url-redirect/#findComment-442735 Share on other sites More sharing options...
tinker Posted January 18, 2008 Share Posted January 18, 2008 oops, I didn't comprehend that bit! Quote Link to comment https://forums.phpfreaks.com/topic/85540-url-redirect/#findComment-442736 Share on other sites More sharing options...
papaface Posted January 18, 2008 Share Posted January 18, 2008 Make a php file with: $url = $_GET['url']; header('Location: '.$url); and then link to it like: <a href="thatphpfile.php?url=http://www.google.com" >Link</a> Should work. Quote Link to comment https://forums.phpfreaks.com/topic/85540-url-redirect/#findComment-442740 Share on other sites More sharing options...
papaface Posted January 18, 2008 Share Posted January 18, 2008 Just realised you are using a select menu. You can use Javascript to pass the url to the php file, but if you want to get away from javascript, there is no way to do it using a select menu. Quote Link to comment https://forums.phpfreaks.com/topic/85540-url-redirect/#findComment-442742 Share on other sites More sharing options...
scottybwoy Posted January 18, 2008 Author Share Posted January 18, 2008 Erm, thanks for all your info. Yeah I know java is seperate from JS I'm just lazy. My Select menu is like this : <form action="$url/php/select_url.php" method="post"> <select id='menu' onchange='submit()' name='menu'> <option>Jump to Product</option> </select> </form> And papface's code works nicely. I use a seperate php method to populate the select menu. So as this one uses the onchange submit() <- I take it that is a javascript function and would not work, however if I use a noscript and include a submit button it will just have a button for the people not enabling JS correct? If so we have a fully functional Submit menu without using any javascript, it IS possible! Quote Link to comment https://forums.phpfreaks.com/topic/85540-url-redirect/#findComment-442760 Share on other sites More sharing options...
papaface Posted January 18, 2008 Share Posted January 18, 2008 onchange='submit()' That <b>is</b> javascript.... lol Quote Link to comment https://forums.phpfreaks.com/topic/85540-url-redirect/#findComment-442767 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.