Captcha Class¶
The Captcha class provides captcha functions.
Calling the Captcha Class¶
$Captcha = $this->Captcha;
Creating CAPTCHA¶
Adding code to controller:
$this->View->assign('captcha', true);
Vesthelm.util.createCaptcha() function used to create CAPTCHA field in ExtJS form:
Ext.define('Vesthelm.view.bulletin_board.bulletin.AddBulletinForm', {
extend: 'Ext.form.Panel',
alias: 'widget.add_bulletin_form',
initComponent: function() {
Ext.apply(this, {
items: [ Vesthelm.util.createCaptcha() ]
});
this.callParent(arguments);
}
});
HTML form without ExtJS:
$captcha_html = $this->Captcha->printCaptcha();
echo $captcha_html;
Checking CAPTCHA¶
if (!$this->Captcha->checkCaptcha()) {
$error = lang('invalid_captcha');
}
echo $error;