Yii框架:reCaptcha试图获取非对象的属性

时间:2012-06-04 08:22:48

标签: php yii recaptcha

我在注册表中使用了recaptcha。昨天我没有问题,但今天,当我开始工作时,我注意到recaptcha不起作用。当我输入正确的代码时,我得到错误:尝试获取非对象的属性

另一件事是,它正在我的网络服务器上工作。我只在localhost上遇到此问题。

这是我使用re验证码的代码:

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 = '6LcsL9ISAAAAADStq9f3mBk_on0G4N7jFSmI8sbP';
                        $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;

        }

        $this->render('create',array(
            'model'=>$model,
        ));
                }else{
                    $this->render('create',array(
            'model'=>$model,
                        ));


                }


    }

编辑:用户在注册成功后即可进入。 我在这一行收到错误:if($this->_identity->errorCode===UserIdentity::ERROR_NONE)

0 个答案:

没有答案