我正在尝试在 cakephp中实现 fun-captcha( http://codecanyon.net/item/fun-captcha/163632 )。
$this->CaptchaGenerator = new CaptchaGenerator();
$this->set('captcha0', $this->CaptchaGenerator->renderCaptcha(0));
$this->set('captcha1', $this->CaptchaGenerator->renderCaptcha(1));
$this->set('captcha2', $this->CaptchaGenerator->renderCaptcha(2));
if ($this->request->is('post')):
$captchaArray['captcha0flag'] = @$this->request->data['captcha0flag'];
$captchaArray['captcha1flag'] = @$this->request->data['captcha1flag'];
$captchaArray['captcha2flag'] = @$this->request->data['captcha2flag'];
for ($i = 0; $i < count($captchaArray); $i++) {
$responseValue[] = $this->CaptchaGenerator->checkCaptcha($captchaArray, $i);
}
pr($responseValue);
在 pr($responseValue) 我得到这个结果
数组( [0] => 1 [1] => 1 [2] => 1 )
这意味着来自 3 个盒子的值是真实的。然后,如果此值为真,我将尝试使用此代码保存我的帖子和标签
if ($responseValue == 1) {
if (isset($temp)) {
$this->Tag->saveMany($temp);
}
$listOfId = $this->Tag->tagIdArray;
$this->request->data['Claim']['Tag'] = $listOfId;
$this->Claim->save($this->request->data);
$this->redirect('/');
}
else {
$this->Session->setFlash('Nop', 'flash', array('alert' => 'error'));
$this->redirect('/start-claim');
}
但是仍然不能提交我显示的 Flash 消息“NOP”的帖子。任何人都可以建议我吗????