Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cake php 2.9登录方法不起作用_Php_Cakephp - Fatal编程技术网

cake php 2.9登录方法不起作用

cake php 2.9登录方法不起作用,php,cakephp,Php,Cakephp,我是新来的蛋糕PHP2.9,我有一个小问题,在登录功能我的代码在视图和登录控制器如下 public function login() { if($this->request->is('post')) { if($this->Auth->login()) { return $this->redirect($this->Auth->redirectUrl())

我是新来的蛋糕PHP2.9,我有一个小问题,在登录功能我的代码在视图和登录控制器如下

 public function login() {

            if($this->request->is('post')) {
                if($this->Auth->login()) {
                    return $this->redirect($this->Auth->redirectUrl());
                } else {
                    $this->Session->setFlash('Invalid Username or Password!');
                }
            }

        }
我的视图/用户/登录文件代码为

登录

DB名称为Users,模型类名为User, DB columns name=用户名和密码


谢谢

请检查您的AppController.php是否对此进行了正确设置

// app/Controller/AppController.php
public $components = array(
    'Auth' => array(
        'loginAction' => array(
            'controller' => 'users',
            'action' => 'login',
        ),
        'authError' => 'Did you really think you are allowed to see that?',
        'authenticate' => array(
            'Form' => array(
                'fields' => array(
                  'username' => 'user_name', //Default is 'username' in the userModel
                  'password' => 'password'  //Default is 'password' in the userModel
                )
            )
        )
    )
);
这里最重要的是

'authenticate' => array(
    'Form' => array(
        'fields' => array(
          'username' => 'user_name', // important!!!!
          'password' => 'password' 
        )
    )
)

详细信息检查

请共享您的身份验证组件代码这是解决方案,Thankyou@HassamAliQazalbash那么你应该接受这个答案。你能告诉我如何创建默认值吗$此->请求->数据['Project']['visible']=2;就像这不起作用一样,您可以设置默认数据库值,也可以在保存之前设置。我正在使用它,但它现在起作用了。谢谢,'if($this->request->is('post')){$this->Project->create();$this->request->data['Project']['visible']=2;if($this->Project->save($this->request->data))'
'authenticate' => array(
    'Form' => array(
        'fields' => array(
          'username' => 'user_name', // important!!!!
          'password' => 'password' 
        )
    )
)