Tips and Tricks in a world of Mix

Install CAPTCHA into default Joomla 1.5 Contact form

captcha image

With all the loads of SPAM people get on a daily basis you would think that the Joomla Dev team would have integrated a CAPTCHA feature into their contact form at the very least. Good thing we got a great community who have attempted to create CAPTCHA functionality for a few of the most widley used forms in Joomla. One of them being the default contact form.

This is a tutorial to install a CAPTCHA plugin into Joomla!. It’s a hack as well as a plugin. But hey, It Works! I wish I could say the same for other CAPTCHA extensions out there.

Download the BIGO CAPTCHA 1.2 plugin from here:

Install the plugin into your Joomla 1.5 website.

Next we have to change the following files:




First we will change the administrator/components/com_contact/contact_items.xml file to give it a new parameter on the backend of Joomla.

After the on line 96 insert the following:

<param name="use_captcha" type="radio" default="1" label="Use Captcha" description="Enable Captcha verification">
			<option value="0">No</option>
			<option value="1">Yes</option>

Next we will change the components/com_contact/controller.php

After line 122 insert the following code:

 if (!$this->_checkCaptcha()) {
 JError::raiseWarning("666","You have entered the wrong CAPTCHA sequence. Please try again.");
 return false;

After line 395 insert the following:

 @author bigo
 @date januray, 2008
 function displaycaptcha() {
 global $mainframe;
 $contactId = JRequest::getVar('contact_id', 0, '', 'int');
 // load the contact details
 $model    = &$this->getModel('contact');
 $qOptions['id'] = $contactId;
 $contact        = $model->getContact( $qOptions );
 $params = new JParameter( $contact->params );
 if ($params->get('use_captcha')) {
 $Ok = null;
 $mainframe->triggerEvent('onCaptcha_Display', array($Ok));
 if (!$Ok) {
 echo "<br/>Error displaying Captcha<br/>";

	function _checkCaptcha() {
		global $mainframe;
		$contactId = JRequest::getVar('id', 0, '', 'int');
		// load the contact details
		$model	= &$this->getModel('contact');
		$qOptions['id'] = $contactId;
		$contact		= $model->getContact( $qOptions );
		$params = new JParameter( $contact->params );
		// not using captcha!
		if (!$params->get('use_captcha')) {
			return true;
		$return = false;
		$word = JRequest::getVar('word', false, '', 'CMD');
		$mainframe->triggerEvent('onCaptcha_confirm', array($word, &$return));
		if ($return) {
			return true;
		} else return false;

The above code allows our captcha to be displayed if chosen in the backend, checked and processed.

Last step is to add it to the contact form.

Open components/com_contact/views/contact/tmpl/default_form.php
Add the following code after line 63:

<?php if ($this->params->get('use_captcha')) { ?>
 <!-- Bigo Captcha -->
 <img src="/index.php?option=com_contact&task=displaycaptcha&contact_id=<?php echo $this->contact->id; ?>">
 <br />
 <input type="text" name="word" />
 <br />
 <?php } ?>



Comments on: "Install CAPTCHA into default Joomla 1.5 Contact form" (3)

  1. Alan said:

    Hi, I tried this but I got the follow error:-

    PHP Fatal error: Call to undefined method ContactController::_checkCaptcha() in\components\com_contact\controller.php on line 126

    do you have any idea’s why it is having a problem?


  2. Hi, do you have similar information on integrating PlayThru plugin to stop captcha from AYAH? I am trying to investigate feasibility of using a game-playing captcha alternative like PlayThru. Any info would be welcome. Thanks.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: