I am new to Codeigniter. I have error when i try to check the email is existed or not. I saw lot of post on Stackoverflow and other website. I can't get any result.
When i try with below coding i got below errors
Unable to access an error message corresponding to your field name Email.(email_check)
Please check my code.
Controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Main extends CI_Controller {
public function index()
{
$this->login();
}
public function login()
{
$this->load->view('login');
}
public function login_validation()
{
$this->load->library('form_validation');
$this->form_validation->set_rules("email","Email","required|trim|callback_email_check");
$this->form_validation->set_rules("password","Password","required|md5|trim|callback_password_check");
if($this->form_validation->run())
{
redirect('main/members');
}
else
{
$this->load->view('login');
}
}
public function members()
{
$this->load->model('model_users');
if($this->model_users->can_log_in())
{
return true;
}
else
{
$this->form_validation->set_message('email_check', 'Incorrect Username/Password');
return false;
}
}
}
MODEL
<?php
class Model_users extends CI_Model
{
public function can_log_in()
{
$this->db->where->('email',$this->input->post('email'));
$this->db->where->('password',md5($this->input->post('password')));
$query = $this->db->get('users');
if($query->num_rows == 1)
{
return true;
}
else
{
return false;
}
}
}
?>