library responsive-captcha
Generate mobile-friendly, accessible CAPTCHAs
theodorejb/responsive-captcha
Generate mobile-friendly, accessible CAPTCHAs
- Sunday, April 16, 2017
- by theodorejb
- Repository
- 5 Watchers
- 8 Stars
- 14 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 3 Forks
- 0 Open issues
- 5 Versions
- 0 % Grown
Responsive Captcha
, (*1)
Prevent form spam by generating random, accessible arithmetic and logic questions., (*2)
Examples:, (*3)
- "What is the fourth letter in snowboard?"
- "What is the sum of four and six?"
- "What is eight multiplied by two?"
- "Which is smallest: sixty-six, one hundred, or twenty-two?"
Users can respond with either the numeric or textual version of an answer (e.g. "16" or "sixteen")., (*4)
For background info on this project, see my blog post: https://theodorejb.me/2012/12/30/responsive-captcha/, (*5)
Install via Composer
composer require theodorejb/responsive-captcha, (*6)
Usage
-
Generate a random question:, (*7)
use function theodorejb\ResponsiveCaptcha\{randomQuestion, checkAnswer};
$qa = randomQuestion();
$realAnswer = $qa->getAnswer(); // save somewhere (e.g. in session or encrypted single-use token)
-
Display question in form:, (*8)
html+php
<label>
<?= $qa->getQuestion() ?>
<input type="text" name="captcha" />
</label>, (*9)
-
Check whether the user's response is correct:, (*10)
$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
}
}
dev-master
9999999-dev
Generate mobile-friendly, accessible CAPTCHAs
Sources
Download
MIT
The Requires
The Development Requires
by
Theodore Brown
v3.0.0
3.0.0.0
Generate mobile-friendly, accessible CAPTCHAs
Sources
Download
MIT
The Requires
The Development Requires
by
Theodore Brown
v2.0.2
2.0.2.0
Generate mobile-friendly, accessible CAPTCHAs
Sources
Download
MIT
The Requires
The Development Requires
by
Theodore Brown
v2.0.1
2.0.1.0
Generate mobile-friendly, accessible CAPTCHAs
Sources
Download
MIT
The Requires
The Development Requires
by
Theodore Brown
v2.0.0
2.0.0.0
Generate mobile-friendly, accessible CAPTCHAs
Sources
Download
MIT
The Requires
The Development Requires
by
Theodore Brown