I am working on a login form using code igniter. I can get the form to display alright but when I click to login I get the following error displayed:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_DB_mysql_driver::$query
Filename: models/membership_model.php
Line Number: 8
This is m membership_model.php file
class Membership_model extends CI_Model{
function validate(){
$this->db->where('username', $this->input->post('username'));
$this->db->where('password', md5($this->input->post('password')));
$this->$query = $this->db->query->get('members');
if($query->num_rows != 0){
return true;
}
}
}
This is my login.php file which is my main controller.
class Login extends CI_CONTROLLER{
function index()
{
$data['main_content'] = 'login_form';
$this->load->view('includes/template', $data);
}
function validate_credentials()
{
//load model to query db
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query){ //if credentials validated
$data = array(
'username' => $this->input->post('username'),
'is_logged_in' => true
);
$this ->session->set_userdata($data);
redirect('site/members_area');
}
else{ //if not validated load login form again.
$this->index();
}
}
This is a screen shot of the error message I am getting
Any ideas what could be going wrong? I haven't a clue! I've looked on the internet but nothing seems to help me. Has anyone encountered this problem. I've been following this tutorial video but it is using an older version of code igniter so I've been making changes as I go.
http://www.youtube.com/watch?v=-fLtTRYQX0M http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-day-6-login/