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

时间:2014-05-22 04:19:56

标签: php cakephp

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;
        }
    }
}

请帮助我,我做错了什么,我是cakephp的新手,谢谢

2 个答案:

答案 0 :(得分:1)

你忘记在重定向之前设置返回

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

More info

答案 1 :(得分:0)

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

必须是:

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

或:

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