등록 양식에 reCaptcha를 구현했습니다. 하지만 올바른 captcha 코드를 입력 할 때 오류가 발생했습니다 :Yii framework : reCaptcha
CCaptchaValidator.action "captcha"가 잘못되었습니다. 현재 컨트롤러에서 이러한 작업을 찾을 수 없습니다.
public function actionCreate()
{
$model=new TblUsers;
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if(isset($_POST['TblUsers']))
{
Yii::import('ext.recaptchalib',true);
$privatekey = '6LfgNLoSAAAAAGBVyqeKK9qH_wG5HIGIDd2KotLB';
$resp = recaptcha_check_answer($privatekey, $_SERVER['REMOTE_ADDR'],
Yii::app()->request->getParam('recaptcha_challenge_field'),
Yii::app()->request->getParam('recaptcha_response_field'));
$model->attributes=$_POST['TblUsers'];
if($resp->is_valid)
{
if($model->save())
if($this->_identity===null)
{
$this->_identity=new UserIdentity($model->username,$model->password);
$this->_identity->authenticate();
}
if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
{
$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
Yii::app()->user->login($this->_identity,$duration);
$this->redirect(array('site/index'));
return true;
}
else
return false;
}
}
else
{
$this->render('create',array(
'model'=>$model,
));
}
}
위의 코드는 captcha를 점검하는 내 컨트롤입니다. 괜찮 으면 DB에 데이터를 저장하고 새로 생성 된 사용자로 로그인해야합니다. 잘못된 코드 일 경우, 현재는 빈 페이지 만 나타납니다. 여기 좀 도와주세요.
빨리 수정 : Ups 나는 올바른 코드로 문제를 해결했지만 모델 규칙에 약간의 정크가 남았지 만 지금은 괜찮습니다. 심지어 코드가 잘못되었을 때 여전히 문제를 처리 할 수있는 도움이 필요하다고 생각해도 이제 빈 페이지가 표시됩니다.
오류가있는 다른 페이지를 렌더링하거나 사용자 로그인 작업을 수행하지 않고 다른 페이지로 리디렉션합니다. – Orlymee