<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<form method="post"><div>
<?php
require 'lib/NamedButtonsCaptcha.php';
$captcha = new NamedButtonsCaptcha();
$captcha->setKeyStorage(new NamedButtonsCaptcha_KeyStorage_Session())
->setNumberOfRequiredButtons(1)
->setMessageTemplate('%s')
->setOutputTemplatePath(dirname(__FILE__) . '/lib/template2.php')
->setButtons(array(
'red' => 'What color is blood?',
'green' => 'What color is leaf?',
'blue' => 'What color is the sky?',
'brown' => 'What color is soil?',
));
if ('POST' === $_SERVER['REQUEST_METHOD']) {
$values = isset($_POST['nbc']) ? $_POST['nbc'] : array();
if ($captcha->isValid($values)) {
echo '<div style="color:green">Verification succeeded</div>';
} else {
echo '<div style="color:red">Verification failed</div>';
}
}
$captcha->render();
?>
<br />
<br />
<input type="submit" value="Verify" />
</div></form>
</body>
</html>
|