I’ve been working on this contact form with a custom captcha for a while now. If you are on github I’ll do a new repository soon.
Ideally this form is for anyone is building a contact form from scratch and wants to have a BASIC security against bad robots.
For this contact form i use two files. The first file called captcha.php and it generates the image with the math. The second file with the source code i call it index.php but it can be named anything you like. Also make sure you are using PHP 5.1 or later.
You can download the file here.
works great
Iām glad to hear matko.
Hi,
Amazing, Thank you for sharing.
Thanks
Thank you Hussain. Again this is not as good as google captcha but it works well against bad robots/spams. The code is clean & simple and you customize it easy. Cheers
Hi,
I insert my email address into the field $sendto = “*******@*****.it”; in index.php
but it doesn’t work.
Somebody can help me? š
Make sure you are developing to an online server and not locally. That’s the first thing I can think of. If that doesn’t work I’ll have a closer look to my code. Thanks
Great job on this tut! I am developing locally using WordPress, all seems to be fine except there seems to be an issue with the displaying on the actually image. What displays next to the math input field is just a broken image file. Any thoughts?
At first thought I assumed it was because of being developed local, but I transferred to hosting site and same thing.
Thanks Jake. The approach for installing this captcha in to wordpress is different. The code is meant for handcoding sites and not for CMS’s. There is great plugins out there you can use like contact-form-7. If I have time one day maybe i’ll make a tutorial of how to install this form in to wordpress.
It’s worth noting that the math part of the solution won’t hold up well against targeted attacks. Math-based captchas can easily be bypassed, as I demonstrate here:
http://www.calcatraz.com/blog/math-based-captcha-security-1551
So the only real security against a targeted attack is the difficulty of extracting text from the image.
But if you’re looking to block untargeted attacks only (which will account for a lot of the attacks most sites see), the captcha given above should work well.
If anyone wants real security, install google recaptcha. As being said this form is a very basic contact form for beginners or designers. Thanks Dan.
thanks for great code and work fine with non-English language.
how i can show errors in front of each input?
thanks
Hi Dariush, if i’m not missing something from your question I would say that it’s better and more valid to use Javascript in order to show errors for each input before submit. Have a look here: http://jqueryvalidation.org/
Thank u