Ashoar Posted April 7, 2009 Share Posted April 7, 2009 Just a quick question. How could you add a new page to the end of a URL? For example i have this url: www.websitehere.com/board.php?forum_num=test Now i have a post.php page which allows a user to insert a post but when i try to add it as a link to the post page i get this url: www.websitehere.com/post.php So how could i add post.php to the end of the original URL so that it will go to post.php? Thanks Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Share Posted April 7, 2009 You can't add a different URL to an existing URL and expect the second URL to be used. You can add something like this on the end www.websitehere.com/board.php?forum_num=test&redirect=post Then check at the start of the script if redirect has been set and then act accordingly. Never take the parameter directly from the URL and use it in an include as this is a security issue but check what the redirect parameter can be then redirect manually. Here's an example... switch ($_GET['redirect']) { case 'post':header('post.php');exit;break; } Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 7, 2009 Author Share Posted April 7, 2009 Oh ok. Thank you for the answer. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Share Posted April 7, 2009 If you want to pass the parameters on the URL as well to the redirect try something like this... $url=$_SERVER['REQUEST_URI']; switch ($_GET['redirect']) { case 'post':$url=stripRedirect('post',$url);header('post.php'.$url);exit;break; } function stripRedirect($txt,$url) { $tmp=str_replace('redirect='.$txt,'',$url); return trim($tmp,'&/?'); } Something like that although that will need some tweaking - but it gives the general idea. 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.