im trying to get a simple login to work with a callback function i created to make sure the password the person entered matches a username they entered in a form. right now if i leave the fields blank and push submit i get “Empty fields”, which is right. But if i enter something in both…i get “It WORKED.”...which it doesn’t work. The username and password im entering do not match so it should return FALSE. any help please?
<?php
class Login extends Controller {
function Login()
{
parent::Controller();
$this->load->database();
$this->load->library('session');
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
}
function index()
{
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean|callback_username_check');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|');
if ($this->form_validation->run() == FALSE)
{
$this->session->set_flashdata('message', 'Empty Fields.');
redirect('mains');
}
else
{
$this->session->set_flashdata('message', 'It WORKED.');
redirect('mains');
}
function username_check()
{
$user = $this->input->post('username');
$pass = $this->input->post('password');
$query = $this->db->query("SELECT loginName,active FROM Member WHERE loginName='$user'
AND password=md5('$pass')");
if($query->num_rows() == 1)
{
return TRUE;
}
else
{
return FALSE;
}
}
}
}
?>