1

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

4
  • And what route are you using to access the index controller? Commented Jul 6, 2016 at 9:12
  • Feeding in any args? Commented Jul 6, 2016 at 9:12
  • betaonetesting.com/watch_new/index.php/admin Commented Jul 6, 2016 at 9:13
  • $this->load->view('pages/sign-in', $data); i.e. pass the view some data, then the view will have access to some data. Commented Jul 6, 2016 at 9:15

1 Answer 1

2

You are not passing the data array into your view. Try this:

$this->load->view('pages/sign-in', $data);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.