2016-07-06 149 views
1

這裏我控制器未定義的變量

class Admin extends CI_Controller { 


function __construct(){ 
    parent::__construct(); 
} 
public function index($msg = NULL) { 
    $data['msg'] = $msg; 

    $this->load->view('pages/sign-in'); 

} 
public function process(){ 
    // Load the model 
    $this->load->model('admin/Admin_model'); 
    // Validate the user can login 
    $result = $this->Admin_model->validate(); 
    // Now we verify the result 
    if(! $result){ 
     // If user did not validate, then show them login page again 
     $msg = '<font color=red>Invalid username and/or password.</font><br />'; 
     $this->index($msg); 
    }else{ 
     // If user did validate, 
     // Send them to members area 
     redirect(base_url().'index.php/home'); 
    }   
} 

,這裏是查看文件我使用:

if(! is_null($msg)) echo $msg; 

它顯示

不確定的變量$味精

+0

你用什麼路徑訪問索引控制器? – ajmedway

+0

餵養任何參數? – ajmedway

+0

http://betaonetesting.com/watch_new/index.php/admin – Pardeep

回答

2

您沒有將數據數組傳遞到您的視圖中。試試這個:

$this->load->view('pages/sign-in', $data); 
+0

它的作品!非常感謝tou – Pardeep

+1

是的..爲什麼不呢!!!!! – Pardeep