Link to home
Start Free TrialLog in
Avatar of mschrimsher
mschrimsher

asked on

getenv("HTTP_REFERER") returns empty string!?

mail("My  Name <me@domain.com>", date("D, M j, Y - h:i a T", time()), "Connection from " . getenv("REMOTE_HOST") . " referred by " . getenv("HTTP_REFERER"), "From: \"Server Access!\" <server@site_server.com>");

I put this on my index page to mail me whenever someone visits my site. The referer returns the URL of my own bookmarks page, sited on the same server as this site, but under a different virtual domain name, but when others visit the site, the referer is blank, perhaps an empty string or a NULL. Why is the referer not being detected? Is there a way to fix it? Bonus question: can I get the IP address resolved with a reverse domain name lookup directly inside this little script?
ASKER CERTIFIED SOLUTION
Avatar of JakobA
JakobA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JakobA
JakobA

Avatar of mschrimsher

ASKER

Jakob: Thanks! I find that about half the referers are being reported now, so I guess I just had a run of bad luck in the beginning. I do get a lot of Google traffic due to AdSense, so that may be part of it--I will correlate the IP addresses to the blank referers and see if there's a pattern. The reference to $_SERVER that you sent said that it was a version 4.1 introduction, and I am using
a 3.x version of PHP now. My ISP offers 4.x as as module, and I have planned to move over for other reasons anyway, so when I do, I will change to $_SERVER. Thanks again!