mynamesleo Posted November 11, 2006 Share Posted November 11, 2006 $_SERVER['HTTP_REFERER']I am tyring to see the url that a user comes from when they visit my site, I assumed I would need $_SERVER['HTTP_REFERER'] in index.php, as this is the first file that loads on my page.[quote]<?phpecho 'aaa';echo $_SERVER['HTTP_REFERER']; [/quote]Thats in index.php, but it just ignores it >:( and doesn't echo anything but the aaa, am I doing something wrong here? Quote Link to comment https://forums.phpfreaks.com/topic/26931-_serverhttp_referer/ Share on other sites More sharing options...
shocker-z Posted November 11, 2006 Share Posted November 11, 2006 test.php[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><?phpecho $_SERVER['HTTP_REFERER'];?><body><a href="test.php">test.php</a></body></html>[/code]that works for me when i click the link it tells me i came from www.ukchat.ws/test.phpRegardsLiam Quote Link to comment https://forums.phpfreaks.com/topic/26931-_serverhttp_referer/#findComment-123163 Share on other sites More sharing options...
mynamesleo Posted November 11, 2006 Author Share Posted November 11, 2006 Hmmm well,http://tubeprogs.com/test.phpThe code in that test.php is[code]<?phpecho "Eh1";echo $_SERVER['HTTP_REFERER'];echo "Eh2";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/26931-_serverhttp_referer/#findComment-123168 Share on other sites More sharing options...
mynamesleo Posted November 11, 2006 Author Share Posted November 11, 2006 Ok that works when I click the link but not if say i type the link into the browser, so the link has to be clicked? Quote Link to comment https://forums.phpfreaks.com/topic/26931-_serverhttp_referer/#findComment-123169 Share on other sites More sharing options...
shocker-z Posted November 11, 2006 Share Posted November 11, 2006 yeah because when you type it in there was no old page which REFERED you to the new one... if you just want the page in which you are on at the moment then just use <?phpecho $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];?>If you do want the page that the user was refered from then your first code was correctRegardsLiam Quote Link to comment https://forums.phpfreaks.com/topic/26931-_serverhttp_referer/#findComment-123172 Share on other sites More sharing options...
nrobi Posted November 11, 2006 Share Posted November 11, 2006 Yeah the link has to be clicked on.I'm not sure if HTTP_REFERER is set otherwise.... if it is, it's the link you just typed in. But technically speaking there is no referer if you type in the link in the browser window.So if you were browsing eBay then you typed in your site, you should not see eBay as the referer. Quote Link to comment https://forums.phpfreaks.com/topic/26931-_serverhttp_referer/#findComment-123176 Share on other sites More sharing options...
mynamesleo Posted November 11, 2006 Author Share Posted November 11, 2006 [quote author=nrobi link=topic=114638.msg466519#msg466519 date=1163265652]Yeah the link has to be clicked on.I'm not sure if HTTP_REFERER is set otherwise.... if it is, it's the link you just typed in. But technically speaking there is no referer if you type in the link in the browser window.So if you were browsing eBay then you typed in your site, you should not see eBay as the referer.[/quote]Oh, ok. Thats what I was hoping it would do, show the page they came from, ebay in that case. Is there nothing that can do that in php? Quote Link to comment https://forums.phpfreaks.com/topic/26931-_serverhttp_referer/#findComment-123180 Share on other sites More sharing options...
wildteen88 Posted November 11, 2006 Share Posted November 11, 2006 The referrer gets passed by the web browser. So if you click a link here that goes to you web site then the browser will log this site as the referrer. The browser wont log this site as the referrer if you type in your websites address in the address bar. As you have not been "referred" Quote Link to comment https://forums.phpfreaks.com/topic/26931-_serverhttp_referer/#findComment-123186 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.