Jump to content

[SOLVED] Get page url


CanMan2004

Recommended Posts

Hi all

Just 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=32

at the end of the url, for example

contact.php?name=David&age=32

When this happens, my IF statement does not work, because the URL has been changed from

contact.php

to

contact.php?name=David&age=32

Does 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 from

contact.php?name=David&age=32

to

contact.php

Can this be done, if it makes sense to anyone.

Thanks

Dave

Link to comment
https://forums.phpfreaks.com/topic/32613-solved-get-page-url/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.