PHP code example of theodorejb / responsive-captcha
1. Go to this page and download the library: Download theodorejb/responsive-captcha library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
theodorejb / responsive-captcha example snippets
use function theodorejb\ResponsiveCaptcha\{randomQuestion, checkAnswer};
$qa = randomQuestion();
$realAnswer = $qa->getAnswer(); // save somewhere (e.g. in session or encrypted single-use token)
$answer = filter_input(INPUT_POST, "captcha");
if ($answer !== null) {
if (checkAnswer($answer, $realAnswer)) {
// code to execute if the captcha answer is correct
} else {
// the answer is incorrect - show an error to the user
}
}
html+php
<label>
<?= $qa->getQuestion()