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 Quote Link to comment 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); Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.