To use this library, make sure you are using PHP 5.6 or latest
Used to get base64 image of generated captcha
Used to get captcha generation id, this id is used to validate the captcha input from client/user
Set the character list that will be used to generate captcha code
Define the captcha code length
Set the width and height of captcha image
Generate captcha
Generate html hidden input of Captcha ID
Generate html image tag
Validate captcha from user input
<?php
require '/path/to/src/Captcha.php';
$captcha = new ZerosDev\Captcha();
$generate = $captcha->length(6)->chars('ABCDEFGHIJKLMNOPQRSTUVWXYZ')->size(170, 50)->generate();
?>
<form>
<input type="hidden" name="captcha_id" value="<?php echo $generate->id(); ?>">
<img src="<?php echo $generate->image(); ?>" />
<label for="captcha">Captcha Code:</label>
<br/>
<input type="text" name="captcha" required>
<br/><br/>
<input type="submit" value="SUBMIT">
</form>
<?php
require '/path/to/src/Captcha.php';
$captcha = new ZerosDev\Captcha();
if( $captcha->validate($_POST['captcha_id'], $_POST['captcha']) )
{
echo 'Valid!';
}
else
{
echo 'Invalid';
}
?>