I am trying to create a basic login, no error checking or anything yet, in an effort to get used to codeigniter. Below is my controller class method that I am attempting to pass the result from my model method back in to verify username and password.
public function login()
{
if (isset($_POST['email'])) {
$this->cdata['email'] = $_POST['email'] ;
} else {
$this->cdata['email'] = "";
}
if (isset($_POST['password'])) {
$this->cdata['password'] = $_POST['password'];
} else {
$this->cdata['password'] = "";
}
$this->load->model("dbaccess");
$this->loggedin = $this->dbaccess->check_input($this->cdata['email'], $this->cdata['password']);
if($this->loggedin == TRUE) {
$this->load->view('carerview', $this->cdata);
} else {
$this->cdata['warning'] = "Check failed ! Please try again";
$this->load->view('mainview', $this->cdata);
}
}
The post from my view seems to be working fine. The post is sent back to the main login/index, to the method login (shown above) below shows my model class which is called in my login method in the controller it only has one method so far. check_input()
class Dbaccess extends CI_Model
{
function __construct()
{
parent::__construct();
}
function check_input($email, $password)
{
$this->db->select('email');
$this->db->from('tablename');
$this->db->where('email', $email);
$this->db->where('password', $password);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return TRUE;
} else {
return FALSE;
}
}
}
When I hit submit on my index page I keep getting the warning no matter what and I can't figure out where the issue is.