Well, I'm doing a simple dashboard with user level where I move to the session with an array of three values, so that's fine, the functions that validate the form, validate the user of the database, if the user is logged in or not, function that retrieves the data from the table validating by the session work perfectly more when I created the function that validates the user level to redirect each to its controller it displays the following error:
login_controller.php
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->model('login_model');
$this->load->model('crud_model');
}
public function index(){
$this->load->view('login_view');
}
public function logando()
{
$regras = array(
array(
'field' => 'usuario_login',
'label' => 'Usuário',
'rules' => 'trim|required|min_length[3]|max_length[32]'
),
array(
'field' => 'senha_login',
'label' => 'Senha',
'rules' => 'trim|required|min_length[6]|max_length[32]'
)
);
$this->form_validation->set_rules($regras);
if($this->form_validation->run() != true || $this->login_model->validate() == FALSE){
$this->load->view('login_view');
}else{
redirect('admin/admin_controller');
} } }
login_model.php
class Login_model extends CI_Model {
function validate()
{
$campo['user'] = $this->input->post('usuario_login');
$campo['pass'] = $this->input->post('senha_login');
$where = array(
'login_user' => $campo['user'],
'senha_user' => md5($campo['pass']),
'status_user' => '1'
);
$this->db->where($where);
$query = $this->db->get('usuarios');
if($query->num_rows == 1)
{
$row = $query->row_array();//PEGA OS DADOS DO USUARIO COMPARADO COM OS CAMPOS
$sess_validate = array(
'session_logada' => TRUE,//SE ELES ESTÁ LOGADO OU NÃO
'session_user' => $row['login_user'],//O NOME DE USUÁRIO QUE VEM DO BANCO
'session_nivel' => $row['nivel_user']//O NÍVEL QUE VEM DO BANCO
);
$this->session->set_userdata($sess_validate);
return TRUE;
}else{
$this->session->set_flashdata('user_erro_model', 'Usuário inexistente ou inativo');
redirect(current_url());
return FALSE;
}
}
public function is_logado()
{
if (trim($this->session->userdata('session_logada')) != TRUE)
{
redirect(index_page());
}
}
public function is_nivel()
{
if($this->session->userdata('session_nivel') == 1){
redirect('admin/admin_controller');
}else{
redirect('user/user_controller');
}
}
public function is_dados_user()
{
$sess['user'] = $this->session->userdata('session_user');
$where = array(
'login_user' => $sess['user']
);
$this->db->where($where);
$query = $this->db->get('usuarios');
$row = $query->row_array();
if($query->num_rows > 0) return $row;
} }
admin_controller.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin_controller extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('login_model');
$this->login_model->is_logado();
$this->login_model->is_nivel();
$this->login_model->is_dados_user();
}
user_controller.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User_controller extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->model('login_model');
$this->login_model->is_logado();
$this->login_model->is_nivel();
$this->login_model->is_dados_user();
}
public function index()
{
$this->load->view('user');
}
public function sair()
{
if($this->session->userdata('session_logada') == FALSE){
redirect(index_page());
}else{
$this->session->sess_destroy();
redirect(index_page());
}
}
}
/* End of file user_controller.php */
/* Location: ./application/controllers/admin/user_controller.php */
I've tried changing the wamp server settings and nothing: (