Here my controller is
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');
}
}
and here is view file i am using:
if(! is_null($msg)) echo $msg;
it shows
undefined variable $msg
$this->load->view('pages/sign-in', $data);i.e. pass the view some data, then the view will have access to some data.