Forum Moderators: coopster
$referer = $_SERVER['HTTP_REFERER'];
$this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];
if ($referer!= $this_url) {
echo "You do not have permission to use this script from another URL.";
}
else {
code that sends the message!
} I'm getting complaints that this form won't work for anyone who has installed Norton Firewall or similar products, that hide the referrer.
Is there a workaround here?
Or another way to restrict use of the form script?
Is the form set up in such a way that you can send email to any email address?
other wise I don't really worry about protecting that way and I just embed the email address into the sending script. That way, even if they spam submit it, it only goes to me.
hm, but maybe I'm overdoing the security here?
[edited by: jatar_k at 11:19 pm (utc) on Mar. 21, 2005]
[edit reason] fixed quote tag [/edit]
The referer test will always not work for some people that really want to contact you so that is a bad way to go. Though you may get a little spam, it is preferable to a customer not being able to use your site.
well, if the email address is in the script and you are testing your vars and not just looping through everything in the $_POST array then you are doing fine.
If you only use the vars that are explicitly in your form then they, at least, are confined to not being able to slip something by. If those vars are also tested for types and accepted values you are pretty much there.