I have one controller and try to load two models (Usermodel and Contentmodel) and also I need to load Form Validation Library. I use Usermodel to do everything with user such as login and register, and I need Contentmodel to do everything with my web content. At first I was able to login and register and I had no problem with Form Validation Library, but then when I add a line $this->load->model('contentmodel');
to load Contentmodel, I suddenly get this error:
If I remove the line $this->load->model('contentmodel');
everything goes back to normal again.
Controller (Controll.php):
defined('BASEPATH') OR exit('No direct script access allowed');
class Controll extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public $lang;
public $logo;
public function __construct () {
parent::__construct();
$this->load->helper('url');
$this->load->helper('form');
$this->load->model('contentmodel');
$this->load->model('usermodel');
$this->load->library('session');
$this->load->library('form_validation');
/*get all user sessions data*/
$this->sesi = $this->session->all_userdata();
$config = $this->contentmodel->load_config();
$this->lang = $config['lang'];
$this->logo = $config['image_logo_path'];
$data['lang'] = $this->lang;
$this->load->view('/header/header');
}
public function panel(){
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('cred', 'Password', 'required');
if($this->form_validation->run() === false){
echo '<center style="position: relative;z-index:10000;font-family: \'Roboto\', sans-serif;color:white;top: 62%;">'.validation_errors().'</center>';
$this->load->view('login');
}else{
$user = $this->usermodel->login();
if($user == 0){
echo '<center class="logerror" style="position: relative;z-index:10000;font-family: \'Roboto\', sans-serif;color:white;top: 62%;">Username or Password incorect. Please try again</center>';
$this->load->view('login');
}else{
$data['data'] = 2;
$data['user'] = $user;
$this->load->view('/header/navbar',$data);
$this->load->view('panel');
$this->load->view('/footer/footer');
}
}
}
And also, if I remove/comment these lines:
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('cred', 'Password', 'required');
/* ... */
if($this->form_validation->run() === false){
/* ... */
}else{
/* ... */
}
Everything goes back to normal again as well.
Please help me. Thanks in advance.