2017-02-23 59 views
0

登錄後,我有一個登錄頁面,我有兩個user_types..one是供應商,另一種是用戶..獲得用戶ID在URL中笨

So..what我想要做的是,每當用戶或供應商從login..they登錄都重定向到dashboard..in,我想在URL中的USER_ID ..

這裏是我的登錄控制器:

公共職能登入() {

$data['error'] ="Invalid Login"; 
      if($this->input->post()) 
      { 

       $user = $this->LoginModel->login($this->input->post()); 
       if(count($user)>0) 
       { 
         $data = array(
          'user_id' => $user['user_id'], 
          'first_name' => $user['first_name'], 
          'email' => $user['email'], 
          'password' => $user['password'] 
          ); 

       $this->session->set_userdata($data); 



      if($user['user_type_id'] == '1') 
      { 

        redirect(base_url('index.php/Login/vendor_dashboard')); 

      } 


     elseif($user['user_type_id'] == '2') 
     { 
       redirect(base_url('index.php/Login/user_dashboard')); 
     } 

     else 
     { 
      redirect(base_url('index.php/Login/dashboard')); 
     } 

     } 
    else 
    { 
     $data["error_message"]="Invalid User Name and Password combination"; 
    } 
} 

$ this-> load-> view('Admin/login_view',$ data);

}

這是我的模型:

function login($post='') 
{ 
$this->db->where(array('email' => $post['email'], 'password' => $post['password'])); 
$query = $this->db->get('users'); 

return $query->row_array(); 
} 

請人幫助我..

如何做到這一點..提前

謝謝..

回答

1

你會做這樣的事情 編輯製作

redirect(base_url('index.php/Login/user_dashboard/'.$this->session->user_id); 
+0

,那麼你可以用$這個 - 它訪問> URI->段(3);在你打電話的函數 –

+0

它的工作..感謝你..感謝很多.. – M5533

+0

請注意我所做的改變,我的意思是它沒有真正必要的,但我已經chaged連接,而不是從會話中獲取數據訪問陣列.......也請接受我的答案,如果它有幫助 –

1

試試這個:

redirect(base_url('index.php/Login/vendor_dashboard?user_id='.$user['user_id']) 
+0

我有另一個懷疑..在儀表板用戶有3個標籤..當他們點擊第一個標籤的頁面將重定向到特定的頁面..在該頁面我也需要調用該user_id ..你可以告訴我怎麼可以我做臨時工 – M5533