CodeIgniter - 消息:未定义的属性:Account_login::$login 和调用非对象上的成员函数 model()



想就这些错误寻求帮助。

控制器名称:Account_login.php型号名称:account_login_model.php

消息:未定义的属性:Account_login::$login文件名:controllers/Account_login.php行号:34回溯:文件:C:\examplep\htdocs\labelercise009\application\controllers\account_login.php线路:34函数:_error_handler文件:C:\examplep\htdocs\labelercise009\application\controllers\account_login.php线路:21功能:运行文件:C:\examplep\htdocs\labelercise009\index.php线路:315功能:需要一次

在非对象上调用成员函数model((消息:在null上调用成员功能model((文件名:C:\examplep\htdocs\labelercise009\application\controllers\account_login.php行号:34回溯:文件:C:\examplep\htdocs\labelercise009\application\controllers\account_login.php线路:21功能:运行文件:C:\examplep\htdocs\labelercise009\index.php线路:315功能:需要一次

这是我的代码:

控制器

?php
class Account_login extends CI_Controller
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$data['title'] = 'Account Login';
$this->load->view('account_login', $data);
}
public function verify()
{
$this->form_validation->set_rules('txtuser', 'Username', 'required');
$this->form_validation->set_rules('txtpass', 'Password', 'required|callback_check_user');
if ($this->form_validation->run() == TRUE) {
echo 'Success';
} else {
$this->index();
}
}
public function check_user()
{
$username = $this->input->post('txtuser');
$password = $this->input->post('txtpass');

$this->login->model('account_login_model');
$login = $this->account_login_model->login($username, $password);

if ($login) {
return true;
} else {
if (isset($_SESSION['error_count'][$username])) {
$_SESSION['error_count'][$username] += 1;
} else {
$_SESSION['error_count'][$username] = 1;
}
$isBlocked = $this->account_login_model->isBlocked($username);
if ($isBlocked) {
$this->form_validation->set_message('check_user', 'Account is temporarily blocked.');
} else if (isset($_SESSION['error_count'][$username]) && $_SESSION['error_count'][$username] > 2) {
$this->account_login_model->block($username);
$this->form_validation->set_message('check_user', '3 consecutive failed login attempts. Account Blocked.');
} else {
$this->form_validation->set_message('check_user', 'Invalid Username/Password');
}
return false;
}
}
}

型号

<?php
class Account_login_model extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->load->database();
}
public function login($username, $password)
{
$condition_array = array(
'user_name' => $username,
'user_pass' => $password
);
$rs = $this->db->get_where('users', $condition_array);
$row_count = count($rs->row_array());
if ($row_count > 0) {
return $rs->row_array();
} else {
return FALSE;
}
}
public function isBlocked($username)
{
$condition_array = array(
'user_name' => $username,
'acc_isBlocked' => 1
);
$rs = $this->db->get_where('accounts', $condition_array);
$row_count = count($condition_array);
if ($row_count > 0) {
return true;
} else {
return FALSE;
}
}
public function block($username)
{
$this->load->library('email');
$email = $this->account_lookup($username, 'acc_email');
$this->email->from('lslayugan@feutech.edu.ph', 'Your Website');
$this->email->to($email);
$this->email->subject('Account Blocked');
$message = $this->load->view('account_blocked', null, TRUE);
$this->email->message($message);
$this->email->send();
$this->db->where('acc_username', $username);
return $this->db->update('accounts', array('acc_isBlocked' => 1));
}
public function account_lookup($username, $return)
{
$rs = $this->db->get_where('account', array('acc_username' => $username));
$row = $rs->row();
return $row->$return;
}
}

可能会发生这样的变化$this->负载->模型("account_login_model"(;

而不是$this->登录->模型("account_login_model"(;

相关内容

  • 没有找到相关文章

最新更新