Welcome Guest, Not a member yet? Register   Sign In
why's that no data showing on my sidebar,even if it's on my admin or user side?
#1
Photo 

this is the picture of my sidebar:
[Image: qyY3Rfr]
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');
}
}
Reply
#2

(This post was last modified: 11-27-2018, 01:22 AM by Pertti.)

Check your $this->session->type value - it looks like it has no fallback (which might be by design), so if it's not either 'admin' or 'user', it will never show anything.
Reply
#3

Maybe i'm wrong but perhaps you're not saving the type in the user session and then you're looking for something that don't exist - nothing to show.
Reply
#4

You can make your base_url look better by doing this:

PHP Code:
<a href="<?php echo base_url('product');?>"

And for your redirects like so:

PHP Code:
redirect(base_url('profile')); 

If your missing css file it will stop your sidebar from showing.

Because it has happened to me before.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(11-28-2018, 02:09 PM)InsiteFX Wrote: And for your redirects like so:

PHP Code:
redirect(base_url('profile')); 

The base_url( ...) part of the above is unnecessary. redirect() will figure out the "base" for you. It should look like this.

PHP Code:
redirect('profile'); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB