this is the picture of my sidebar:
this is my code in my sidebar:
Code:
<aside class="main-sidebar">
<!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
<!-- Sidebar user panel -->
<br><br>
<!-- sidebar menu: : style can be found in sidebar.less -->
<ul class="sidebar-menu" data-widget="tree">
<?php
if($this->session->type == "admin"){ ?>
<li>
<a href="<?php echo base_url(); ?>userdata">
<i class="fa fa-users"></i><span>User Data</span>
</a>
</li>
<li>
<a href="<?php echo base_url(); ?>category">
<i class="fa fa-list-alt"></i><span>Category</span>
</a>
</li>
<li>
<a href="<?php echo base_url(); ?>brand">
<i class="fa fa-book"></i><span>Brands</span>
</a>
</li>
<li>
<a href="<?php echo base_url(); ?>product">
<i class="fa fa-product-hunt"></i><span>Products</span>
</a>
</li>
<li>
<a href="#">
<i class="fa fa-first-order"></i><span>Orders</span>
</a>
</li>
<?php
} elseif($this->session->type == "user"){ ?>
<li>
<a href="#">
<i class="fa fa-first-order"></i><span>Orders</span>
</a>
</li>
<?php
}
?>
</ul>
</section>
<!-- /.sidebar -->
</aside>
then this is my code in my login:
Code:
$this->form_validation->set_rules('username', 'Username', 'trim|required');
$this->form_validation->set_rules('password', 'Password', 'trim|required');
if($this->form_validation->run() == TRUE){
$username = $this->input->post('username');
$password = $this->input->post('password');
$email = $this->input->post('email');
$user_id = $this->login_model->login($username, $password);
if($user_id){
$session = array(
'user_id' => $user_id,
'username' => $username,
'email' => $email,
'logged_in' => true
);
$this->session->set_userdata($session);
foreach ($user_id as $users){
if($users->type == admin){
redirect(base_url() . 'category');
} elseif($users->type == user){
redirect(base_url() . 'profile');
}
}