Class: Zebra_Form_Captcha
source file: /includes/Captcha.php
Class Overview
XSS_Clean
|
--Zebra_Form_Control
|
--Zebra_Form_Captcha
Class for CAPTCHA controls.
Author(s):
Copyright:
- (c) 2006 - 2013 Stefan Gabos
Class methods
constructor __construct()
void
__construct (
string
$id
,
string
$attach_to
,
[
$storage
= 'cookie']
)
Adds a CAPTCHA image to the form.
Do not instantiate this class directly! Use the add() method instead!
You must also place a textbox control on the form and set the "captcha" rule to it!
(through set_rule())
Properties of the CAPTCHA image can be altered by editing the file includes/captcha.php.
// create a new form
// add a CAPTCHA image
$form->add('captcha', 'my_captcha', 'my_text');
// add a label for the textbox
$form->add('label', 'label_my_text', 'my_text', 'Are you human?');
// add a CAPTCHA to the form
$obj = $form->add('text', 'my_text');
// set the "captcha" rule to the textbox
'captcha' => array('error', 'Characters not entered correctly!')
));
// don't forget to always call this method before rendering the form
if ($form->validate()) {
// put code here
}
// output the form using an automatically generated template
$form->render();
Parameters:
| string |
$id |
Unique name to identify the control in the form. This is the name of the variable to be used in the template file, containing the generated HTML for the control. // in a template file, in order to print the generated HTML
// for a control named "my_captcha", one would use:
echo $my_captcha;
|
| string |
$attach_to |
The id attribute of the textbox control to attach the CAPTCHA image to. |
|
$storage |
|
Top
method toHTML()
string
toHTML (
)
Generates the control's HTML code.
This method is automatically called by the render() method!
Tags:
| return: |
The control's HTML code |
Top