spryce Posted April 7, 2011 Share Posted April 7, 2011 $_SERVER['HTTP_REFERER']; <-- this returns the full path. Can I return the referring page name only? ie) somepage.php Cheers Link to comment https://forums.phpfreaks.com/topic/232984-how-to-return-the-referring-page-name-only/ Share on other sites More sharing options...
phil88 Posted April 7, 2011 Share Posted April 7, 2011 Totally untested, but you could probably do something along this lines of: $page = substr(strrchr($_SERVER['HTTP_REFERER'], '/'), 1); Link to comment https://forums.phpfreaks.com/topic/232984-how-to-return-the-referring-page-name-only/#findComment-1198257 Share on other sites More sharing options...
kenrbnsn Posted April 7, 2011 Share Posted April 7, 2011 Use a combination of parse_url and basename <?php $x = parse_url($_SERVER['HTTP_REFERER']); echo basename($x['path']); ?> Ken Link to comment https://forums.phpfreaks.com/topic/232984-how-to-return-the-referring-page-name-only/#findComment-1198260 Share on other sites More sharing options...
alphazulu Posted April 7, 2011 Share Posted April 7, 2011 This is what I have done in past $ref = $_SERVER['HTTP_REFERER']; $ref = explode("/", $ref); echo "$ref[2]"; if referer was http://www.website.com/folder then that code will output www.website.com on another note it also gives you folder names Link to comment https://forums.phpfreaks.com/topic/232984-how-to-return-the-referring-page-name-only/#findComment-1198277 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.