Я получаю следующую ошибку в строке 17 Fatal error: Call to a member function set_rules() on a non-object
У меня есть библиотека form_validation
при автозагрузке.
public function login()
{
$this->form_validation->set_rules('userName','userName', 'required|valid_email|trim|max_length[99]|xss_clean');
$this->form_validation->set_rules('userPassword','userPassword', 'required|trim|max_length[200]|xss_clean|callback__checkUser');
if($this->form_validation->run() === TRUE) {
// set CLEAN data in the session.
redirect('admin/dashboard');
}else{
$this->index();
}
}
Контроллер
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Login extends CI_Controller {
public function index()
{
$data['companyName'] = $this->core_model->companyName();
$data['pageTitle'] = "Administration Login";
$this->load->view('admin/assets/header', $data);
$this->load->view('admin/login.php', $data);
$this->load->view('admin/assets/footer');
}
public function login()
{
$this->form_validation->set_rules('userName','userName', 'required|valid_email|trim|max_length[99]|xss_clean');
$this->form_validation->set_rules('userPassword','userPassword', 'required|trim|max_length[200]|xss_clean|callback__checkUser');
if($this->form_validation->run() === TRUE) {
// set CLEAN data in the session.
redirect('admin/dashboard');
}else{
$this->index();
}
}
function _checkUser(){ // Private function
extract($_POST);
$login = $this->admin_model->check_login($userName,$userPassword,$userGroup,$userEmail,$userActive);
if(! $login){
$this->session->set_flashdata('login_error', TRUE);
$this->form_validation->set_message('_checkUser','Sorry your %s is not correct');
return FALSE;
}else{
if($user->userGroup == "admin" && $user->userActive == "yes")
{
$this->session->set_userdata('logged_in', TRUE);
$this->session->set_userdata('userID', $user->id);
$this->session->set_userdata('userName',$user->userName);
$this->session->set_userdata('firstName',$user->userFirstName);
$this->session->set_userdata('lastName',$user->userLastName);
$this->session->set_userdata('userEmail',$user->userEmail);
$this->session->set_userdata('userGroup',$user->userGroup);
$this->session->set_userdata('userActive',$user->userActive);
}else{
$this->session->set_flashdata('login_error', TRUE);
$this->form_validation->set_message('_checkUser','Sorry your %s is not correct');
return FALSE;
}
}
}
}
/* End of file login.php */
/* Location: ./application/controllers/admin/login.php */