I have a PHP based website that uses coupon codes. I can restrict search engines from finding the landing page of a coupon code (like if it was an ad on another page).
But I also want to restrict the coupon code so that it only works if they came from the site serving the coupon code. That way, if someone find the code, they can’t just post it on a blog. Granted, it’s good business to have a Coupon code go viral, but we need it to be restricted for marketing analysis.
So if I put an ad on http://www.examplead.com, and someone comes to our website from clicking the ad, I want to allow the coupon code to work. If they come from http://www.exampleblog.com, or any other site other than http://www.examplead.com, I don’t want to allow the coupon code to work.
I don’t need help with writing code that will disable/enable coupon codes, but I need help with filtering where someone is coming from, and then executing a function based on that.
If someone else has a better method for keeping track of coupon codes, please let me know.
The simplest way is to check the value of
$_SERVER['HTTP_REFERER']. It can be forged, but it doesn’t require the other side to do anything.