2014-11-04 104 views
-1

我已經更改了我的代碼,我正在獲取用戶電子郵件和密碼,但無法獲取名稱和ID?什麼問題?加上我得到一個錯誤未定義的索引ID和名稱?沒有從codeigniter中的數據庫獲取用戶名和ID

public function login() { 
    $users = array (

      'email' => $this->input->post ('email'), 
      'password' => $this->input->post ('password'), 

      TRUE 
    ); 

    if (count ($users)) { 

     $my_data = array (

       'email' => $users['email'], 
       'password' => $users['password'], 
       'name' => $users['name'], 
       'id' => $users['id'], 
       'loggedin' => TRUE 
     ); 

     $this->session->set_userdata ($my_data); 
     var_dump($my_data); 
    } 
} 

這是我的var_dump

'session_id' => string 'fa71c96123ea05c8c10ec8c49d125f5c' (length=32) 
'ip_address' => string '127.0.0.1' (length=9) 
'user_agent' => string 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:33.0) Gecko/20100101  
'last_activity' => int 1415150854 
'user_data' => string '' (length=0) 
'email' => string '[email protected]' (length=22) 
'password' => string 'Kingston12' (length=10) 
'name' => null 
'id' => null 
'loggedin' => boolean true 

回答

1

檢查你的代碼:

 public function login() { 
     $users = array (

       'email' => $this->input->post ('email'), 
       'password' => $this->input->post ('password'), 
       'id' => $this->input->post ('id'), 
       'name' => $this->input->post ('name') 
     ); 

     if (count ($users)) { 

      $my_data = array (

        'email' => $users['email'], 
        'password' => $users['password'], 
        'name' => $users['name'], 
        'id' => $users['id'], 
        'loggedin' => TRUE 
      ); 

      $this->session->set_userdata ($my_data); 
      var_dump($my_data); 
     } 
    } 
+0

我下面的TUTS加教程THT – syedsafir 2014-11-04 12:43:09

+0

的任何想法,因爲你不接受ID和名稱。或只需添加這些行 id'=> $ this-> input-> post('id'), 'name'=> $ this-> input-> post('name') 或write print_r ($ _ POST);登錄功能啓動後,並檢查您收到的郵件。 – amit 2014-11-04 12:46:26

相關問題