忘记密码的未定义索引yii

时间:2015-08-10 12:46:01

标签: php yii forgot-password

我在yii工作并创建忘记密码。我尝试将http://www.yiiframework.com/wiki/744/how-to-create-forgot-password-in-yii-sending-email-to-reset-password/用于与https://github.com/ruderbytes/forgot-password-in-yii相同的忘记密码。 但是我有一个错误未定义的索引:Lupa ,这在行动中忘记了$ getEmail行。

 public function actionForgot()
     {
        $getEmail=$_POST['Lupa']['email'];
        $getModel= Users::model()->findByAttributes(array('email'=>$getEmail));
        if(isset($_POST['Lupa']))
        {
            $getToken=rand(0, 99999);
            $getTime=date("H:i:s");
            $getModel->token=md5($getToken.$getTime);
            $namaPengirim="Owner Jsource Indonesia";
            $emailadmin="fahmi.j@programmer.net";
            $subjek="Reset Password";
            $setpesan="you have successfully reset your password<br/>
                <a href='http://yourdomain.com/index.php?r=site/vertoken/view&token=".$getModel->token."'>Click Here to Reset Password</a>";
            if($getModel->validate())
        {
            $name='=?UTF-8?B?'.base64_encode($namaPengirim).'?=';
            $subject='=?UTF-8?B?'.base64_encode($subjek).'?=';
            $headers="From: $name <{$emailadmin}>\r\n".
                "Reply-To: {$emailadmin}\r\n".
                "MIME-Version: 1.0\r\n".
                "Content-type: text/html; charset=UTF-8";
            $getModel->save();
                            Yii::app()->user->setFlash('forgot','link to reset your password has been sent to your email');
            mail($getEmail,$subject,$setpesan,$headers);
            $this->refresh();
        }

        }
    $this->render('forgot');
}

任何人都可以提前感谢你。

1 个答案:

答案 0 :(得分:0)

更改

public function actionForgot()
     {
        $getEmail=$_POST['Lupa']['email'];
        $getModel= Users::model()->findByAttributes(array('email'=>$getEmail));
        if(isset($_POST['Lupa']))
        { //..

致:

public function actionForgot()
     {
        if(isset($_POST['Lupa']) && isset($_POST['Lupa']['email'])) {
           $getEmail=$_POST['Lupa']['email'];
           $getModel= Users::model()->findByAttributes(array('email'=>$getEmail));
//...