[eluser]cideveloper[/eluser]
Also don't post all your code. Only post the relevant sections. That is just lazy. Also you post every single line but I don't see a function that is called when calling "callback_username_check"
P.S. This is a fix for the question not the answer
Code:
<?php
class Account extends Controller
{
function Account()
{
parent::Controller();
$this->load->library(array('form_validation', 'session'));
$this->load->helper(array('url', 'form'));
$this->load->model('account_model');
$this->_salt = "123456789987654321";
}
function login()
{
$this->form_validation->set_rules('username', 'Username','xss_clean|required|callback_username_check');
$this->form_validation->set_rules('password', 'Password','xss_clean|required|min_length[4]|max_length[12]|sha1|callback_password_check');
$this->_username = $this->input->post('username');
$this->_password =sha1($this->_salt.$this->input->post('password'));
if($this->form_validation->run() == FALSE)
{
$this->load->view('account/login');
}
else
{
$this->account_model->login();
$data['message'] = "You are logged in! Now go take a look at the ". anchor('account/dashboard', 'Dashboard');
$this->load->view('account/success', $data);
}
}
function password_check()
{
$this->db->where('username', $this->_username);
$query = $this->db->get('users');
$result = $query->row_array();
if($query->num_rows() == 0)
{
$this->form_validation->set_message('password_check', 'username not found!');
return FALSE;
}
if($result['password']==$this->_password);
{
return TRUE;
}
}
}
?>