我正在使用CakePHP 2.9版本。 Userscontroller中的$this->Auth-login()
函数不会获取用户名。即使我的数据库(用户)有'用户名'和'密码'字段。它正在重定向到else语句。
UsersController:
public $components = array('Paginator','Auth','Session','Flash');
public function beforeFilter() {
$this->Auth->allow('login','logout');
}
public function login(){
if($this->request->is('post')){
$this->set('user1',$this->Auth->request);
if($this->Auth->login()){
return $this->redirect($this->Auth->redirect(['controller'=>'accessors','action'=>'index']));
}
else{
$this->Flash->set('Please check with username and password.');
} }}
login.ctp
echo $this->Form->create('User');
echo $this->Form->input('username',$options=array('div'=>array('class'=>'input text required'),'type'=>'text','autocomplete'=>'off'));
echo $this->Form->input('password',$options=array('div'=>'input password required'));
echo $this->Form->button('Submit', $options=array('type'=>'submit'));
echo $this->Form->button('Reset', $options=array('type'=>'reset')).'</br>';
Here is the screenshot通过DebugKit
获取指定值的变量有人能告诉我哪里弄错了吗?