我在蛋糕 2.7 框架上的 PHP 中有一个登录功能,它不会超过第一if
条语句。条件似乎总是错误的,我真的很困惑为什么。我没有正确执行请求吗?任何帮助将不胜感激。
登录()
function login() {
if (!empty($this->request->data) && $this->Auth->user()) {
// Delete all old tokens
$this->Tour->recursive = -1;
$this->Tour->deleteAll(array('Tour.userid' => $this->Auth->user('userid')));
// Create a new token
$this->Tour->create();
$this->Tour->save(array('token' => md5(rand()), 'userid' => $this->Auth->user('userid')));
// Update login count
$user = $this->User->read(null, $this->Auth->user('userid'));
$user['User']['logincount']++;
$this->User->saveField('logincount', $user['User']['logincount']);
// Update last login time
$this->User->saveField('lastlogin', date('Y-m-d h:m:s'));
echo 'doesnt work';
if ($this->request->is('post')) {
if ($this->Auth->login()) {
echo 'authLogin';
return $this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Username or password is incorrect'), 'default', array(), 'auth');
}
}
}
}