Skip to content

nettraction/Math_Captcha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 

Repository files navigation

Math_Captcha

PHP-based Simple Math Captcha

Usage

  1. Include the file. (Note: session_start() must be called before instantiating this class)
require_once 'MathCaptcha.php';
  1. Instantiate MathCaptcha
$cpa = new MathCaptcha();
  1. First call to the page (before user submit)
if( /* is this a submit? */ ){
  $captcha_val = $_REQUEST['captcha'];

  if( $cpa->validate($captcha_val) ){
    echo 'Correct';
  }else{
    echo 'Incorrect';
  }
}else{
  // Initialize captcha
  $cpa->reset_captcha();
}
  1. Display Captcha/Challenge text within a form (using get_captcha_text() method)

Simple

echo 'Solve this simple Math: ' . $cpa->get_captcha_text() . " = ?";

Rich Text

$captcha_text = 'Result of <i>{operand1}</i> {operator} <i>{operand2}</i> is?';
echo $cpa->get_captcha_text($captcha_text);

Example

Captcha In Active

About

PHP-based Simple Math Captcha

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages