Php codeigniter中视图中的未定义变量
这是我的控制器Php codeigniter中视图中的未定义变量,php,codeigniter,Php,Codeigniter,这是我的控制器 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(){ // Lo
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');
}
}
它表明
未定义变量$msg
您没有将数据数组传递到视图中。试试这个:
$this->load->view('pages/sign-in', $data);
您使用什么路径访问索引控制器?输入任何参数?
$this->load->view('pages/sign-in',$data)代码>即,向视图传递一些数据,然后视图将访问一些数据。
$this->load->view('pages/sign-in', $data);