Software Engineer, builder of webapps

reCaptcha for Codeigniter 2

Every time I make a new website with a user registration, I usually end up using a reCaptcha somewhere in the process. A while ago, I discovered a reCaptcha library on the Codeigniter forums. And since then, Ive modified it a little bit to work with Codeigniter 2.0and have placed it on Github where everyone can access it. Below is just an example of the Controller (included in the repository) so you can see how it all comes together.

 * Sample recaptcha controller implementation
 */class Recaptcha_Controller extends Controller{
    public function  __construct()

    public function index()
        $data = array('mainData' => '',
                      'recaptcha' => $this->recaptcha->get_html()

        $this->load->view('recaptcha_view', $data);

    public function submit()
        $ipAddress = $this->input->ip_address();
        $challengeField = $this->input->post('recaptcha_challenge_field');
        $responseField = $this->input->post('recaptcha_response_field');

        if ($this->recaptcha->check_answer($ipAddress, $challengeField, $responseField))
            // success!!echo 'Success!';
            // redirect here or do what you want
            // failure!!// redirect back to the recaptcha page