Skip to content

PHP Captcha Creator & Validator class that generate Captcha to block automatic form bots, and compares it with the value received from the user.

License

Notifications You must be signed in to change notification settings

msbatal/PHP-Captcha-Creator-Validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PHP Captcha Creator & Validator

SunCaptcha is a simple PHP captcha creator and validator class.

The goal of this class is to let you; Generate Captcha to block automatic form bots, and compare it with the value received from the user.

Installation

To utilize this class, first import SunCaptcha.php into your project, and require it. SunCaptcha requires PHP 7.0+ to work.

require_once ('SunCaptcha.php');

Initialization

Simple initialization:

$captcha = new SunCaptcha();

Advanced initialization:

$captcha = new SunCaptcha(120, 40, '#ffffff', '#ffffff', '#000000'); // params: width, height, text color, line color, background color

All parameters are optional.

Width value can not lesser than 90 and Height value can not be lesser than 30.

You can use short or long Base-16 (Hex) codes for color parameters. Eg. #000 or #000000

Creation

$captcha = new SunCaptcha();
echo '<img src=' . $captcha->create() . '>';

Validation

$captcha = new SunCaptcha(); // create empty object
$input = '9779fd'; // get input value from user
if ($captcha->validate($input) === true) { // if validated
    echo 'Captcha value is correct.';
} else {
    echo 'Captcha calue is wrong.';
}

About

PHP Captcha Creator & Validator class that generate Captcha to block automatic form bots, and compares it with the value received from the user.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages