简体   繁体   English

注册后重定向在cakephp中不起作用

[英]Redirect is not working in cakephp after registration

function signup(){
    if(!empty($this->data)){


        if(isset($this->data['User']['password2']))
            $this->data['User']['password2hashed'] = $this->
            Auth->password($this->data['User']['password2']);
        $this->User->create();
        if($this->User->save($this->data)){
            $this->Session->setFlash('Congratulatios, you have signed up');
            $this->redirect('updateProfile');

        }
        {
            $this->Session->setFlash('There was an error signing up, Please try again later');
            $this->data= null;
        }
    }
}

Please help me, what am I doing wrong, I am new to cakephp, thanks 请帮助我,我在做什么错,我是Cakephp的新手,谢谢

you forgot to set return before redirection 您忘记设置重定向之前的返回值

 return $this->redirect(
            array('controller' => 'users', 'action' => 'updateProfile')
        );

More info 更多信息

 $this->redirect('updateProfile'); //this is wrong

it must be: 一定是:

 return $this->redirect("/users/updateProfile");

or: 要么:

 return $this->redirect("updateProfile");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM