Skip to content

Math CAPTCHA Library for CodeIgniter, generate random sum of numbers

Notifications You must be signed in to change notification settings

wasksofts/codeigniter-math-captcha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeIgniter-math-captcha

Math CAPTCHA Library for CodeIgniter, generate random sum of numbers

Install

Install the libray for using by autoload.

$ composer require wasksofts/codeigniter-math-captcha

usage

controller

 class Test extends CI_Controller
 {
    public function index()
  {
         $this->load->library('mathcaptcha');
	$this->form_validation->set_rules('captcha', 'captcha', 'trim|xss_clean|required|callback__check_captcha');

	if ($this->form_validation->run()) {
		echo 'success';
	}
	//how to controll whether to use this library or another 
	$data['show_captcha']    = TRUE;
	$data['captcha_html']    = $this->mathcaptcha->create_captcha();
	$this->load->view('form_view', $data);
  }

  //this is callback function for validation
   public function _check_captcha($code)
  {
	return $this->mathcaptcha->_check_captcha($code);
  }
    }

add this html part to your form

             <form method="post" action="<?= $this->uri->uri_string() ?>">
		<table>
			<tr>
				<td colspan="3">
					<p>Answer this math quiz : <?php echo $captcha_html; ?></p>
				</td>
			</tr>
			<tr>
				<td>
				<?= form_input(["id" => "captcha", "name" => "captcha", "type" => "text", "placeholder" => "answer", "required" => "true"]); ?>  <br>
				<?php echo form_error('captcha'); ?> <br />
				</td>
			</tr>
		</table>
		<button type="submit">Submit</button>
	</form>

View Usage

Alt text

Bugs and feature requests

Have a bug or a feature request? please email mukamanusteven@gmail.com

donate

About

Math CAPTCHA Library for CodeIgniter, generate random sum of numbers

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages