我有一個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