Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.