Adding CAPTCHA To Joomla Contact Forms

If you haven't noticed, my preferred method for building websites is using the Joomla! Content Management System. After having built approximately 20 or so Joomla-powered websites, I have picked up a few tips and tricks here and there, largely from the incredibly friendly user-base of other Joomla! developers.

 

One such trick is adding CAPTCHA verification to the core Joomla! contact form.

 



What is CAPTCHA?

 

Here is the definition from reCAPTCHA.net.


A CAPTCHA is a program that can tell whether its user is a human or a computer. You've probably seen them - colorful images with distorted text at the bottom of Web registration forms. CAPTCHAs are used by many websites to prevent abuse from "bots," or automated programs usually written to generate spam. No computer program can read distorted text as well as humans can, so bots cannot navigate sites protected by CAPTCHAs.

 



Why is it helpful?

 

Occasionally, I receive e-mails through Joomla! contact pages that look like this.

 

From: fodhve < This e-mail address is being protected from spambots. You need JavaScript enabled to view it >
Date: Thu, Nov 12, 2009 at 8:56 PM
Subject: IVM Web Solutions: yWsfZdZuUdSyIAQrhN
To:  This e-mail address is being protected from spambots. You need JavaScript enabled to view it


This is an enquiry e-mail via http://ivmwebsolutions.com/ from:
fodhve < This e-mail address is being protected from spambots. You need JavaScript enabled to view it >


5ShISF  xvomirpwqubr, [url=http://fesojnybgmvi.com/]fesojnybgmvi[/url], [link=http://vxzyqunqrfpv.com/]vxzyqunqrfpv[/link], http://blozvkwzbvhr.com/

 

This appears to be spam generated by a "bot" as described in the CAPTCHA definition above. It's not something I care to have to clean out of my e-mail inbox, so after receiving a few of these e-mails I went looking for a solution.

 

A fellow Joomla! developer named Piet Nutbey, founder of JoomTorial.com, quickly replied to my inquiry with the following.

 



How to install CAPTCHA in the Joomla! core contact form?

 

There are two parts to this solution:

 

1. The Joomla! extension called JEZ reCAPTCHA Integrator
http://www.joomlaez.com/joomla-plugins/joomla-captcha-solution.html

2. The 3rd party account at http://recaptcha.net



The Steps

1. Download and install the JEZ reCAPTCHA Integrator

 

2. Create an account at http://recaptcha.net

 

3. Click on My Account

 

4. Click on + Add a New Site. That will generate a Public Key and a Private Key.

 

5. Using the Plugin Manager in the Joomla! backend, input these keys in your JEZ reCAPTCHA Integrator plugin and enable the plugin.

 

6. Using your FTP client (ex. FileZilla), navigate to /components/com_contact/views/contact/tmpl/default_form.php and copy this file to your desktop.

 

7. Open this php file and locate the code that looks like this...

 

<button class="button validate" type="submit"></button>

 

8. Above that line of code, paste the following...

 

<br />
<?
global $mainframe;
$mainframe->triggerEvent('onCaptchaDisplay');
?>

<br>

 

9. Save this updated file to your desktop and then copy it to /templates/your_template/html/com_contact/contact/default_form.php.


NOTE: If that specific directory/subdirectory combination does not exist, create the directories.




Now with the extension enabled, keys filled in from reCAPTCHA, and the default_form.php file tweaked, your contact page should now have CAPTCHA verification to prevent those pesky spambots from bothering you.


THANKS AGAIN, PIET!

Written on Wednesday, 27 January 2010 15:23 by Rob McBryde

Viewed 1224 times so far.
Like this? Tweet it to your followers!

Rate this article

(1 vote)
blog comments powered by Disqus