Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

100% SPAM Free Protection Using PHP and jQuery

Hello Friends,

I am working with PHP and MySql since last 5 years and I was keep complained from my clients that they are getting spam emails via contact forms. Solution is Captcha ? Oops. You are judging me wrong. As I said I am PHP Developer over 5 years of experience so I have used captcha obviously for the forms.

Even if I placed captcha, clients are getting spam emails. It may be possible that spammers may have some script which will read captcha and submit forms automatically. It was out of my mind to come up with the solution and make them spam free. Here is what I think for it.

I come up with 2 solutions and both works for my clients.

Solution 1.
– Pick your required field.
– Make an ajax call onblur or onkeyup event for that field.
– Create a session on server side with that ajax call.
– Now when form submit, check with that session. If that session is created than its a real person who submit the form and not the spammer.
– This will make sure that visitor has physically enter the required field and all other fields.

Solution 2.
– Build your own captcha instead of using popular readymade captcha solution. Its simple to create one. Here is how you can achieve it.
– Create 2 random numeric number and save them in session.
– In answer box, ask visitors to enter sum or subtraction or any other mathematic operation with those numbers. Every time page refresh, keep different mathematic operation and save it to session to use it while form submits.
– This will also make sure that visitor will physically enter the information on site and submit the form.

Problem with Solution 1 is when user does not have javascript enabled on browser. But only 5% people comes in this case.

I hope this helps! Cheers.


1 Comment

Leave a Reply

Your email address will not be published.