开发者

Error after redirection using CakePHP

I have created some code called LoginController. Whenever Admin gets successfully logged in I redirect the page to index.

However, I got an error like "problem on loading page".

This is my code:

<?php
class LoginController extends AdminAppController {
var $name = 'Login';
var $uses = array('Admin.Login');
var $sessionkey= '';
/*function beforeFilter()
{

    if($this->Session->read('user')=='Admin' || $this->params['action']=='login')
    {开发者_JAVA百科
        echo "in"; exit;
    }
    else
    {
        echo "else"; exit;
        $this->Session->setFlash('Login first','flash_failure');
        $this->redirect(array('action'=>'login'));

    }
}*/

function index() {


}

function login()
{
    //pr($this->data); exit;

    if(!empty($this->data))
    {
        $results = $this->Login->findByEmail($this->data['Login']['email']);
        if(!empty($results) && $results['Login']['password']== md5($this->data['Login']['password']))
        {   

            $this->Session->write('user', 'Admin');

            $results['Login']['last_login']=date("Y-m-d H:i:s");
            $this->Login->save($results);
            $this->Session->setFlash('Login successfully.', 'flash_success');
            $this->redirect(array('controller'=>'login','action' => 'index'));



        }

    }
}
}
?>

Can anyone help me? Thanks.


I got your problem.

IT goes into the infinite loop.ANd that is why you got in the Page loading error.

As you did not distinguish between admin login and client login you are facing this issue.

So my suggestion is that create new same function with diff name called as admin login

And set the router for admin login. regards, ARCHIT.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜