我使用 Cake Php 创建了一个简单的登录表单。当我点击登录按钮时,会出现一个警告
Illegal offset type [CORE\Cake\Model\Model.php, line 2734
我使用链接作为参考 http://bakery.cakephp.org/articles/SeanCallan/2007/04/17/simple-form-authentication-in-1-2-xx
Login.ctp的代码
登录
<?php echo $this->Form->create('User', array('action' => 'login'));?>
<?php echo $this->Form->input('username');?>
<?php echo $this->Form->input('password');?>
<?php echo $this->Form->submit('Login');?>
<?php echo $this->Form->end(); ?>
2.模态文件
find(array('username' => $data['username'], 'password' => md5($data['password'])), array('id', 'username')); if(empty($user) == false) return $user['User']; 返回假;} } ?>3.控制器文件
<?php
App::uses('AppController', 'Controller');
class UsersController extends AppController
{
var $name = "Users";
var $helpers = array('Html', 'Form');
var $components = array("Auth");
function index()
{
}
function beforeFilter()
{
$this->__validateLoginStatus();
}
function login()
{
if(empty($this->data) == false)
{
if(($user = $this->User->validateLogin($this->data['User'])) == true)
{
$this->Session->write('User', $user);
$this->Session->setFlash('You\'ve successfully logged in.');
$this->redirect('index');
exit();
}
else
{
$this->Session->setFlash('Sorry, the information you\'ve entered is incorrect.');
exit();
}
}
}
function logout()
{
$this->Session->destroy('user');
$this->Session->setFlash('You\'ve successfully logged out.');
$this->redirect('login');
}
function __validateLoginStatus()
{
if($this->action != 'login' && $this->action != 'logout')
{
if($this->Session->check('User') == false)
{
$this->redirect('login');
$this->Session->setFlash('The URL you\'ve followed requires you login.');
}
}
}
}
?>
为什么会这样。我是新来的。PHP 聊天室中的一些开发人员建议我不要使用 Cake PHP。任何帮助表示赞赏