我已经下载了一个recaptchalib 并成功实现了recaptcha 并在我的页面上显示recaptcha 但我无法验证它......我如何验证recaptcha
在查看文件中
<div id="recaptcha_div"></div>
<script type="text/javascript">
$(function(){
Recaptcha.create("<?php echo Configure::read("recatpch_settings.public_key")?>", 'recaptcha_div', {
theme: "red",
callback: Recaptcha.focus_response_field});
});
</script>
控制器的登录动作
public function login() {
App::import('Vendor', 'recaptchalib', array('file' => 'recaptchalib/recaptchalib.php'));
$resp = recaptcha_check_answer (Configure::read("recatpch_settings.private_key"),
$_SERVER["REMOTE_ADDR"],
$this->params['form']["recaptcha_challenge_field"],
$this->params['form']["recaptcha_response_field"]);
pr($resp);
exit();
if (!$resp->is_valid) {
$this->Session->setFlash('The reCAPTCHA wasn\'t entered correctly. Please, try again.');
} else {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash('Your username/password combination was incorrect');
}
}
}
}
我无法验证验证码。如果我输入正确的验证码以及用户名和密码,我想登录用户。