Here it is, an AJAX’d contact form with a captcha. I had an idea to code this about a week ago and thought would be a tough job to do but it wasn’t that tough to code when I started doing it. The only place where I had to spend a lot of time was, pondering how to pass the value from the ‘textarea’ to the PHP preserving the line breaks. After googling for about an hour and reading different articles I finally got what was required, I just had to escape(): the variable before sending it to the PHP script.

On a positive note, I didn’t really have any problem with running this script on IE (I usually have to break my head over this matter). To prelude its features, I guess it does everything you’d normally except a contact form to do. It sanitizes all the variables, checks for the Email structure and disabled the submit button once the email is sent to prevent mass emails. I would like to thank SecondVersion and Psyrens for the PHP backend & ajax captcha respectively. As usual I’m lazy to provide a detailed documentation about it and would *make sure* that I write one in the future. But the whole script isn’t obfuscated at all, you’d just have to edit some constants and woo! it’s done.

I’m currently working on integrating this script as a wordpress plugin. Please let me know any bugs/commments/feedback by commenting below or contacting me. Show-off your own modified version of this script here :P

Script Demo : http://hakc.net/ajax-contact-form-captcha-demo/

Script Download : http://hakc.net/…./….zip

This post has 6 comments. Add your own.
Trevor Ratcliffe - 22 May 08 at 01:41:02

Very nice, i am trying it out on my site, the only prob is, if the frm is submited with missing fields, the validation works ok and stops and informs user as it should, but it also disables the submit button, and the user can not fill in the missing data and resend with out refreshing the page?

[...] 2)Ajax güvenlik korumalı iletişim formu gerçekten sade hoş bir görünüme sahip olan bir iletişim form’u.bu form’u diğerlerinden ayırt eden şey captcha resimli güvenlik uygulaması olması.uygulama demosu için buraya , indirmek için buraya tıklamanız yeterli. Ajax iletişim formu | Resmi büyüt ..! [...]

mayur - 17 Jun 08 at 19:03:18

Great script! I, however, am having some issues - I want to get get of all the subdirectories and such so that the main file is ‘contact.php’ and all other files are ‘contact_NAME.OF.FILE’.

I think I’ve got it all but I can’t seem to generate an image. Where is the reference to the Anorexia font? What am I missing?

Muhammad Kashif Majeed - 20 Jun 08 at 23:37:50

Great work, another useful script by you

Cihan Kaya - 14 Aug 08 at 06:31:06

Captcha is not work:S

bogyvet - 16 Aug 08 at 00:40:22

I try for two days without sucess. Everything is working on Localhost, but when I upload to server - I can not see any image. I try “server_test.php” bc catcha used in form is from securityimage. OK server have all needed for captcha:

# PHP - 4.3.0 or greater, PHP5 compatible
# GD support in PHP. FreeType required for TTF fonts. Version 2.0.33 required for gif output. GD is bundled with PHP since version 4.3
# Session Support

Any sugesstions.

Thanks in advance