PHP HTTP Referrer

aaronfarr picture aaronfarr · Mar 15, 2011 · Viewed 23.1k times · Source

I have a page which accepts POSTs from a remote site. I would like to detect the domain that these POSTs are coming from. I realize that it can be spoofed but it is better than nothing. I have tried accessing the HTTP_REFERER variable but it just returns null.

The page accepts POSTs from sources like PayPal (instant payment notifications) and other payment gateways.

How can I get the referring call?

Answer

Matthew Flaschen picture Matthew Flaschen · Mar 15, 2011

You spelled Referer correctly. It should be:

$_SERVER['HTTP_REFERER']