I have a problem to create permission menu,
Oke I have a table user..
username, password, permission.
I have a function in model like this..
function valid_login($username, $password)
{
$query = $this
->db
->where('username', $username)
->where('password', md5($password))
->limit(1)
->get('user'); /
if ($query->num_rows() == 1) {
return $query->row_array();
}
else
{
return FALSE;
}
}
The value post from controller, The Script like this..
public function index()
{
if ( isset($_SESSION['permission']) ) {
redirect('home_controller/home');
}
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required|min_length[4]');
if ( $this->form_validation->run() == TRUE ) {
$this->load->model('m_user');
$result = $this->m_user->valid_login(
$this->input->post('username'),
$this->input->post('password')
);
if ($result == TRUE) {
$_SESSION['permission'] = ????;
redirect('home_controller/home');
}
}
$this->load->view('login_form');
}
I dont understand, how to get field permission value from model. I need that value to create $_SESSION..
And myView like this..
<?php
if($_SESSION['permission']=="Administrator"){
$this->load->view('administrator_menu');;
}else{
$this->load->view('user_menu');;
}
?>
Thanks for the attention.. Anyone can help me..