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 t
This works for me pretty well:
https://stackoverflow.com/a/17958676/2635701
<form action="http://www.yourdomain.com/subscribe"
method="POST"
onsubmit=
"document.getElementById('www.yourdomain.com.referrer').value=window.location;" >
<!-- hidden input for field starts with a domain registered by you
just so that it's unlikely to clash with anything else on the page -->
<input type="hidden" id="www.yourdomain.com.referrer" name="referrer"/>
your email: <input name="email" type="text"/>
... rest of form ...
<input type="submit" value="Subscribe"/>
</form>
$_SERVER['HTTP_REFERER']
with a single R, try var_dump($_SERVER) for more info.
You spelled Referer correctly. It should be:
$_SERVER['HTTP_REFERER']
You are right that the referrer is easy to spoof, however there is a better solution. Read the ipn documentation in which they mention validation mechanisms. Never trust the user.