CanMan2004 Posted January 2, 2007 Share Posted January 2, 2007 Hi allJust wondering if anyone can help me, basically im displaying the URL of the page on each page of my site, the code I use is[code]<?$url = $_SERVER['REQUEST_URI'];print $url;?>[/code]One of the things I do is to highlight the area in the navigation the user is on by doing an if statement.The problem I have is that one of my pages has a form on it, which the method is GET, so when I use the form, it can put a?name=David&age=32at the end of the url, for examplecontact.php?name=David&age=32When this happens, my IF statement does not work, because the URL has been changed fromcontact.phptocontact.php?name=David&age=32Does this make sense?What I need to do, is to figure out a way to use the following[code]<?$url = $_SERVER['REQUEST_URI'];print $url;?>[/code]but to remove anything after .php, so it would change a URL fromcontact.php?name=David&age=32tocontact.phpCan this be done, if it makes sense to anyone.ThanksDave Quote Link to comment https://forums.phpfreaks.com/topic/32613-solved-get-page-url/ Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 A quick solution would be....[code]<?php$url = explode('?',$_SERVER['REQUEST_URI']);print $url[0];?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32613-solved-get-page-url/#findComment-151691 Share on other sites More sharing options...
Jessica Posted January 2, 2007 Share Posted January 2, 2007 You might also think about using POST instead of GET. Quote Link to comment https://forums.phpfreaks.com/topic/32613-solved-get-page-url/#findComment-151740 Share on other sites More sharing options...
Daniel0 Posted January 2, 2007 Share Posted January 2, 2007 Try taking a look at [url=http://php.net/parse_url]parse_url()[/url]. Quote Link to comment https://forums.phpfreaks.com/topic/32613-solved-get-page-url/#findComment-151753 Share on other sites More sharing options...
CanMan2004 Posted January 3, 2007 Author Share Posted January 3, 2007 thanks everyone Quote Link to comment https://forums.phpfreaks.com/topic/32613-solved-get-page-url/#findComment-151801 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.