Documentation

Captcha


The captcha helper provides a simple math captcha:


Methods


getMathQuestion()


Creates the question from random variables, which are also saved to the session.


<form method="post">
<?php echo Captcha::getMathQuestion(); ?>
<input type="text" name="answer" />
<input type="submit" name="submit" />
</form>

correctAnswer(integer $answer)


Checks the given answer if it matches the addition of the saved session variables.


if (isset($_POST['submit'])) {
    if (Captcha::correctAnswer($_POST['answer'])) {
        // Do something...
    }
}