I’m wanting to create a “Was this helpful?” button, just with the options Yes/No. I don’t have a database ready to receive the input, so, I’d just like each button to simply send an email to me if it was clicked. Maybe the email could just say, “a site user found this page helpful/unhelpful: [URL]”.
I’ve coded email feedback forms in PHP before but can’t think of where I’d start with this. I’m not sure if an email can be sent with just one click of a javascript button. Does anyone see this as a possibility?
You could use a library such as jquery to do an ajax post to a proxy PHP script:
Though one issue you will run into is people refreshing and clicking multiple times, potentially spamming you with email. A good basic protection against this is to set a
$_SESSIONvariable or cookie with their IP address, and the page, so they can’t keep clicking again and again.Please note however that they can simply use another IP address, or say another page is helpful. However that would be a lot of work just for that.
Also for sanity purposes it would be a good idea to also check the page variable against
parse_url()to be safe.