NuCaptcha CodeIgniter Plugin


Documentation

CodeIgniter is an open source web application framework for use in building dynamic web sites with PHP. The CodeIgniter framework has helper functions and libraries for form input and validation. The NuCaptcha CodeIgniter Plugin allows you to display and validate NuCaptcha using the CodeIgniter form libraries.

Installation of the NuCaptcha CodeIgniter Plugin is easy!

Install Instructions

  • Download and Unzip the latest NuCaptcha CodeIgniter Plugin
  • Copy helpers/MY_form_helper.php into your application/helpers directory.
  • Copy libraries/MY_Form_validation.php into your application/libraries directory.
  • Add a new entry named 'nucaptcha_clientkey' to your application/configs/config.php file with your NuCaptcha Client Key (sign up here to get your client key)

 001  // Append the following to your application/config.php file:
 002  
 003  /*
 004   |--------------------------------------------------------------------------
 005   | NuCaptcha Configuration
 006   |--------------------------------------------------------------------------
 007   */
 008  
 009  // Get your free client key from http://console.nucaptcha.com
 010  $config['nucaptcha_clientkey'] = 'YOUR CLIENT KEY HERE';
 011  

NuCaptcha enables input rendering and validation by extending CodeIgniters built-in 'form' helper and 'form_validation' library.

Simply include these libraries as you would in any other form implementation and you're good to go.

Add NuCaptcha to your forms

First, render 'nucaptcha' fields in your view. Make sure the CodeIgniter form helper has been loaded first.

 001  <!-- Other form view controls here ... -->
 002  
 003  <?= form_label('Human Verification:', 'nucaptcha-answer') ?>
 004  
 005  <?= form_error('nucaptcha-answer') ?>
 006  <br />
 007  
 008  <?= form_nucaptcha(array(
 009      'id' => 'mynucaptcha',
 010      'class' => 'mynucaptcha',
 011      'tabindex' => 4,
 012      'purpose' => Leap::PURPOSE_COMMENT )) ?>
 013  
 014  <!-- Submit button here ... -->
 015  

Next, add 'nucaptcha' a validation rule in your controller. This time, make sure the CodeIngitor form_validation library is loaded

 001  // The 'nucaptcha' validation rule is implemented as an extension to the built-in library
 002  $this->load->library('form_validation');
 003  
 004  // Add the 'nucaptcha' validation rule to nucapthca-answer.
 005  // No need to add the 'required' rule - nucaptcha fields are always treated as such
 006  $this->form_validation->set_rules(
 007          'nucaptcha-answer',
 008          'NuCaptcha Answer',
 009          'nucaptcha');
 010  
 011  

Sample Code

See controllers/sample.php and views/nucaptcha_*.php provided in the NuCaptcha CodeIgniter Plugin download package for a full working example

Requirements

NuCaptcha has the following runtime requirements:

  • PHP 5.1 or newer
  • PHP mcrypt module must be installed and active (this is the case for most PHP installations)
  • A NuCaptcha Client Key. Get yours FREE here
  • This plugin was written for CodeIgniter 2.0 but should be easily modified to work in older versions.

Support

We're here to help! If you have any questions please contact us!