I have a difficulty on my program. The error say :
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_DB_mysqli_result::$level
Filename: controllers/Auth.php
Line Number: 30
Backtrace:
File: C:\xampp\htdocs\PKLTelkom\Telkom2\application\controllers\Auth.php Line: 30 Function: _error_handler
File: C:\xampp\htdocs\PKLTelkom\Telkom2\index.php Line: 315 Function: require_once
Here's my controller named "Auth" :
<?php
/**
*
*/
class Auth extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('m_login');
}
public function index()
{
$this->load->view("login");
}
public function AksiLogin()
{
$username = $this->input->post('username');
$password = $this->input->post('password');
$passwordx = md5($password);
$login = $this->m_login->data_login($username, $passwordx);
$tes = count($login);
if ($tes > 0) {
//ambil detail data
$row = $this->m_login->data_login($username, $passwordx);
$level = $row->level;
//daftarkan session
$data_session = array('level' => $level);
$this->session->set_userdata($data_session);
//direct page
if ($level == 'superadmin') {
redirect('superadmin');
}
else if ($level == 'admin') {
redirect('admin');
}
}
else {
$this->index();
}
}
public function logout()
{
$this->session->unset_userdata("login");
$this->session->unset_userdata("username");
redirect ('index.php/auth');
}
}
?>
Here's my models named "M_Login" :
<?php
class M_login extends CI_Model
{
function data_login($username, $password)
{
$this->db->where('username', $username);
$this->db->where('password', $password);
return $this->db->get('akun');
}
}
?>
$level = $row->level;
. You're not returninglevel
in your query. – ourmandavelevel
? – Ulfah Putri