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?

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 Commented Feb 20, 2019 at 16:55

2 Answers 2

2

Try this one

redirect('/dashboard/index');
Sign up to request clarification or add additional context in comments.

5 Comments

Calling one controller from another isn't really the same as redirecting the request.
Correct, but i guess he wants to load a new page so this will work
Indeed not the same but one should not end up doing this in the first place, a redirect should be good
Unless the OP needs the variable ($usuario) that was set before the redirect for something. We don't really know enough about the context.
He should do query's on a Model , normally i do it on a model not in the controller
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?

2 Comments

Please don't write comments as answers. If the question has been asked and answered before, the question should be marked as a duplicate.
Please check the Dashboard_Controller instead Dashboard_controller in library load

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.