Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2003
    Location
    UK
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Obtaining A Page name from URL

    Im very new to PHP, so excuse my ignorance..

    Say I wanted to hide bits of text/images on certain page names (i.e test.php), would that be possible with the...

    parse_url($_SERVER["HTTP_REFERRER"]);

    If so, how could I pick out the name of a page....

    Like.. if a url has : http://www.mydomain.com/test.php?catid=8
    and say I wanted to find out what the php file is called?
    Can I do this, i.e:

    if ($page == "test.php") {
    blah blah
    }

    $page could be from a 'function' routine or something?

    Can this be done, as this would make coding simpler for me.

    TIA and sorry if I confused you all

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Posts
    345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If I understand, you want to know the name of the previous page users are coming from. This was given to me in other post:

    PHP Code:
    $full_url parse_url($_SERVER['HTTP_REFERER']);
    $url basename($full_url['path']); 
    Is that what you need?

  • #3
    New to the CF scene
    Join Date
    May 2003
    Location
    UK
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry, I need the ''current' url..... I want to design an external navigation php page and ''include'' it in my main pages.

    For example: If the page name is ''search.php'', the navigation page (which will be included in this page) will check the url, and then execute the relevant ''if'' statement.
    If you understood that? :s

  • #4
    Regular Coder
    Join Date
    Feb 2003
    Posts
    345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    change REFERER for SELF:
    PHP Code:
    $full_url parse_url($_SERVER['PHP_SELF']);
    $url basename($full_url['path']); 
    [edited]
    Actually with this is enough:
    PHP Code:
    $url basename($_SERVER['PHP_SELF']); 
    [/edited]
    Last edited by maltrecho; 10-29-2003 at 07:14 PM.

  • #5
    New Coder
    Join Date
    Sep 2003
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Php_Self isnt that good :-/

    It returns
    blah/blah/blah/blah.php instead of just blah.php calling from
    localhost/blah/blah/blah/blah.php

    I made some code to return just the blah.php partand will release it soon

  • #6
    Regular Coder
    Join Date
    Feb 2003
    Posts
    345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, both options above are just working fine with me.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •