View Full Version : getting less info than REFERER is giving me
10-15-2003, 11:46 PM
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?
10-16-2003, 08:01 AM
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:rolleyes:
10-16-2003, 12:50 PM
With parse_url() and basename() you can do that:
$urlParts = parse_url($_SERVER['HTTP_REFERER']);
$file = basename($urlParts['path']);
10-16-2003, 02:11 PM
Thanks guys, the second option is what I need, but I'll be carefull 'cause I've read (http://www.php.net/manual/en/reserved.variables.php) HTTP_REFERER does not always work as expected. :thumbsup:
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.