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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2003
    Posts
    345
    Thanks
    0
    Thanked 0 Times in 0 Posts

    getting less info than REFERER is giving me

    I'm thinking about something I could do if I could know the previous page the user is coming from (always inside my site). When I use $_SERVER['HTTP_REFERER'], the var is giving me for example: http://www.mysite.com/files/thispage.php?m=12&set=true but what I really need is only: thispage.php. Is there any other predefined var to get that or should I use a preg_replace or so?

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i would say you shlould go with preg_replace, and it shouldnt be too difficult either unless ur pages have names with ? in them... but i cant remember if thats allowed or not

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    With parse_url() and basename() you can do that:

    PHP Code:
    $urlParts parse_url($_SERVER['HTTP_REFERER']);
    $file basename($urlParts['path']);
    print 
    $file
    De gustibus non est disputandum.

  • #4
    Regular Coder
    Join Date
    Feb 2003
    Posts
    345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks guys, the second option is what I need, but I'll be carefull 'cause I've read HTTP_REFERER does not always work as expected.


  •  

    Posting Permissions

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