[eluser]ibnclaudius[/eluser]
The set rules are working, but run() don't. Why?
Code:
function login() {
if ($this->input->post('action') == 'login') {
$this->form_validation->set_rules('username', 'Usuario', 'trim|required|alpha_numeric');
$this->form_validation->set_rules('password', 'Senha', 'trim|required|alpha_numeric');
if ($this->form_validation->run()) {
$data = array('username' => $this->input->post('username'),
'password' => $this->input->post('password'),
);
if ($this->Usermodel->read('users', $data)) {
$this->form_validation->set_message('login', 'Login ok.');
} else {
$this->form_validation->set_message('login', 'Login not ok.');
}
}
}
$data['page_title'] = "Login";
$data['query'] = $this->Usermodel->get_user();
$this->load->view('header', $data);
$this->load->view('login');
$this->load->view('footer');
}
Code:
function read($table, $data) {
$query = $this->db->get_where($table, $data);
if ($query->num_rows() == 0) {
return FALSE;
} else {
return TRUE;
}
}
The function read() is ok because I use it in other places and its fine.