Source for file numeral-captcha.php
Documentation is available at numeral-captcha.php
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<title>HTML_QuickForm2_Element_Captcha_Numeral demo</title>
div.element.error input {
// Ignore E_STRICT errors coming from some modules
// You may not need to do this. For development purposes only
// Include main quickform class
require_once 'HTML/QuickForm2.php';
// Include the numeral captcha class file. necessary because
// the QuickForm2 Captcha is separate from QuickForm2 itself.
require_once 'HTML/QuickForm2/Element/Captcha/Numeral.php';
// Register the numeral captcha element with QuickForm2
HTML_QuickForm2_Factory ::registerElement (
'HTML_QuickForm2_Element_Captcha_Numeral'
$form = new HTML_QuickForm2 (
// Add some normal elements
$username = $form->addElement ('text', 'username')
->setLabel ('Your username');
$username->addRule ('required', 'Username is required');
$username->addRule ('minlength', 'Username is too short', 3 );
$password = $form->addElement ('password', 'password')
->setLabel ('Your password');
$password->addRule ('required', 'Password is required');
// Add the captcha element. no need to add rules!
$captcha = $form->addElement (
// Set some captcha specific options
)->setLabel ('Anti-Spam question');
echo '<h3>Form data valid</h3>';
echo 'In a real form, we would register the user now with the following data:';
// Clear the session, otherwise the user can re-submit the form
// again and again without solving the captcha again
$captcha->clearCaptchaSession ();
Documentation generated on Mon, 11 Mar 2019 15:55:05 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|