我怎樣才能解決這個問題。當我運行這段代碼我收到以下錯誤我已經加載了會議庫還是我收到此錯誤
這是我的控制器
public function __construct(){
parent::__construct();
}
public function index() {
$this->load->database();
$this->load->helper('form', 'url');
$this->load->library('session');
}
public function process() {
$this->load->model('login_model');
$result = $this->login_model->validate();
if (!$result) {
$msg = '<font color=red>Invalid username and/or password.</font><br />';
$this->load->view(base_url().'index',$msg);
} else {
if ($_SESSION['utype'] == 2 || $_SESSION['utype'] == 1) {
redirect(base_url() . 'admin/dashboard');
}
if ($_SESSION['utype'] == 3 && !empty($_POST['urlValue'])) {
redirect($_POST['urlValue']);
}
if (empty($_POST['urlValue'])) {
redirect('/');
}
}
}
這是我的模型
public function validate() {
$username = $this->security->xss_clean($this->input->post('email'));
$password = $this->security->xss_clean($this->input->post('password'));
$pwd = base64_encode($password);
$this->db->where('email', $username);
$this->db->where('password', $pwd);
$query = $this->db->get('adduser');
$row = $query->row();
if (count($row) > 0) {
$row = $query->row();
$data = array(
'uid' => $row->id,
'uname' => $row->firstname,
'utype' => $row->usertype,
'uemail' => $row->email,
'validated' => true
);
$this->session->set_userdata($data);
return $row;
}
return $row;
}
我得到這個問題:
Severity: Notice
Message: Undefined property: Index::$session
Filename: core/Model.php
Line Number: 77
Backtrace:
File: D:\xampp\htdocs\savepaise\application\models\Login_model.php
Line: 42
Function: __get
File: D:\xampp\htdocs\savepaise\application\controllers\Index.php
Line: 31
Function: validate
File: D:\xampp\htdocs\savepaise\index.php
Line: 315
Function: require_once
Fatal error: Call to a member function set_userdata() on a non-object in
D:\xampp\htdocs\savepaise\application\models\Login_model.php on line 42
A PHP Error was encountered
Severity: Error
Message: Call to a member function set_userdata() on a non-object
Filename: models/Login_model.php
Line Number: 42
我認爲你需要不加載控制器構造函數中所有圖書館索引功能 – JYoThI
在您的文章中autoload.php –
編輯格式添加會話庫。你的問題題目太長,問題代碼不正確。和你的問題的文本是不正確的 – mshomali