For those of you that don’t already have CAPTCHA running on your contact forms, or are in need of a free PHP contact form with CAPTCHA that you can easily install on your site, you have come to the right place.
For this contact form I am using reCAPTCHA. The main reason is because I feel it is one of the easier CAPTCHA’s for visitors to use because typing real words is easier than typing random strings of text. Secondly, reCAPTCHA heps to digitize scanned books – read more about it here.
While reCAPTCHA is a simple script that can be freely added to your site, the directions for PHP deployment are not intended for the novice. So, I have put together a free open source contact form script using the reCAPTCHA and made it available here.
Download
Installation
Step 1
The first thing you will need to is get registered at reCAPTCHA by adding your site here. Once you have added your site you will be given a set of public and private API keys. These will be used in the contact form script to activate the reCAPTCHA service.
Step 2
Download and unzip the script to your computer and open contact.php and contact_form.php in your favorite text editor (or notepad if you don’t have one).
On line 10 of contact.php you will need to insert your public key from reCAPTCHA:
$publickey = “yourpublickeygoeshere“;
On line three of contact_form.php you must add your private key from reCAPTCHA:
$privatekey = “yourprivatekeygoeshere“;
On lines 67 of contact_form.php you must replace the email address with the address you want your form submissions to be sent to and modify the subject line if desired. On line 68 you must specify a redirect URL for completed form submissions. Typically this is a “thank you” page that can be used to track conversions.
mail(“you@email.com“,”New Web Contact“,stripslashes($msg), $mailheaders);
header(“Location: http://www.somesite.com“);
Step 3
Copy the entire contents of your edited contact.php and paste the block of code into your site’s HTML where you want your contact form to appear. Don’t forget this must be a PHP page to work.
Step 4
Upload your newly edited contact page from Step 3, along with the contac_form.php and recaptchalib.php and place all three files in the same directory.
That’s All!
Just visit your new contact forms with reCAPTCHA and send yourself a test message to ensure that everything is working correctly.
If you run into any problems or want to provide additional modifications to this script, please join in the conversation below.

Download the Script








