[eluser]Achmed1[/eluser]
Im getting this error message evertime when i want to query or want to search in the database from the model.
Undefined name and pass; line 17
LoginControler
Code:
<?php
class LoginController extends CI_Controller{
public function index(){
$this->load->view('login');
}
public function check_login(){
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required|callback_verifyUser');
if($this->form_validation->run() == FALSE){
$this->load->view('login');
}else{
redirect('HomeController/index');
}
}
public function verifyUser()
{
$name = $this->input->post('username');
$pass = $this->input->post('password');
$this->load->model('LoginModel');
if($this->LoginModel->login($name, $pass)){
return true;
}else{
$this->form_validation->set_message('verifyUser' , 'incorret email');
}
}
}
?>
LoginModel
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class LoginModel extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
public function login(){
$this->db->select('name', 'pass');
$this->db->from('members');
$this->db->where('name', $name);
$this->db->where('pass', $pass);
$query = $this->db->get();
if($query->num_rows()== 1){
return true;
}else{
return false;
}
}
}