0

I have the Login_controller:

if ($query->num_rows() == 1){
    $usuario = $query->row();
    $this->load->library('../controllers/Dashboard_controller');
} 

And I have the Dashboard_Controller:

public function index(){
    $this->load->view("dashboard/Dashboard_view");          
}
}

But, I got a message error:

A PHP Error was encountered Severity: Notice Message: Undefined property: Dashboard_controller::$load Filename: libraries/Form_validation.php Line Number: 147 Backtrace: File: C:\xampp\htdocs\local\acjum1\application\controllers\Login_controller.php Line: 34 Function: library File: C:\xampp\htdocs\local\acjum1\index.php Line: 315 Function: require_once

An uncaught Exception was encountered Type: Error Message: Call to a member function helper() on null Filename: C:\xampp\htdocs\local\acjum1\system\libraries\Form_validation.php Line Number: 147 Backtrace: File: C:\xampp\htdocs\local\acjum1\application\controllers\Login_controller.php Line: 34 Function: library File: C:\xampp\htdocs\local\acjum1\index.php Line: 315 Function: require_once

What am I doing wrong?

M. Eriksson
  • 13,450
  • 4
  • 29
  • 40
Xavier
  • 3
  • 1
  • short answer: HMVC is not supposed to work this way. Controllers shouldn't call other controllers. You could redirect from one controller to another and pass data using flashdata, tempdata, regular session data (not recommended) or other means, but not invoke controllers from within other controllers. See [this](https://stackoverflow.com/questions/14165895/how-to-load-a-controller-from-another-controller-in-codeigniter) – Javier Larroulet Feb 20 '19 at 16:55

2 Answers2

2

Try this one

redirect('/dashboard/index');
0

This question was asked before. Basically you are calling the controller but not the index function. Please refer to : How to load a controller from another controller in codeigniter?

  • Please don't write comments as answers. If the question has been asked and answered before, the question should be marked as a duplicate. – M. Eriksson Feb 20 '19 at 15:42
  • Please check the Dashboard_Controller instead Dashboard_controller in library load – PHP Geek Feb 21 '19 at 04:39