我有一个Zend_Captcha
问题,当页面被提交并且验证码的isValid()
方法被调用时,它总是返回false。这是在推动我的坚果,因为就我而言,这应该起作用。zend_captcha总是失败isValid()
我通过在控制器
$captcha = new Zend_Captcha_Image('captcha',
array(
'captcha' => array(
'name' => 'graduatesignupcaptcha',
'wordlen' => 6,
'font' => $this->config->captcha->font,
'imgDir' => $baseUrl.'/images/captcha/',
'imgUrl' => $this->config->webserver->name.'/images/captcha/',
)
)
);
$captcha->setHeight(80)
->setTimeout(300);
我做平常表单验证的作用函数的顶部声明这一点,所有的作品开始,但它是我来的时候,以验证值输入到表格对于验证码,它总是返回false。
//next we check the captcha text to ensure that the form is a person not a script
$captchaText = $form->getElement('captchainput')->getValue();
$captchaId = $form->getElement('captchaid')->getValue();
//$captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_'.$captchaId);
$captchaArray = array(
'id' => $captchaId,
'input' => $captchaText
);
if(!$captcha->isValid($captchaArray)){
$log->log(implode(",",$captcha->getErrors()), Zend_Log::DEBUG);
$form->getElement('captchainput')->setErrors(array('messages' => 'Bad security code'));
$formFailed = true;
}
我检查,以确保该我得到和储存在我的形式正在生成图像匹配一个隐藏的元素是我做这个ID,但无论总是失败。
我是否缺少一些简单的东西?还是有更好的方式来处理这个?
谢谢,
感谢,它使用上述帮我找到问题是与$ captchaId问题。谢谢 – 2009-12-14 21:20:30