I’m working on a login system for codeigniter and after the login form is submitted, the page just comes up blank. I have the following code, with echo’s inserted to help me find out where things go wrong.
I have development mode set in the index.php mode and E_ALL in php.ini and receive errors on some other pages successfully.
Controller for /account/login:
public function login()
{
echo "made it back into controller";
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = "Log in";
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
if ( $this->form_validation->run() === FALSE )
{
echo "unable to validate";
$this->load->view('templates/header', $data);
$this->load->view('account/login', $data);
$this->load->view('templates/footer', $data );
}
else
{
echo "attempting to login";
if ( $this->account_model->login() == FALSE )
{
echo "failed";
$this->load->view('templates/header', $data);
$this->load->view('account/login', $data);
$this->load->view('templates/footer', $data );
}
else
{
echo "success";
$this->load->view('templates/header', $data);
$this->load->view('account/successfullogin', $data);
$this->load->view('templates/footer', $data );
}
}
}
login() method from Model, called by controller:
public function login ()
{
require 'application/libraries/PasswordHash.php';
$t_hasher = new PasswordHash(8, FALSE);
$password = $this->input->post('password');
$hash = $t_hasher->HashPassword($password);
echo "hashed";
$query = $this->db->query('SELECT `login_token` FROM `Users` WHERE `username` = "'.$this->input->post('username').'" AND `password` = "'. $this->input->post('password').'"');
echo "query made";
$rowCount = $query->num_rows();
echo "query counted";
if ( $rowCount == 1 ) {
echo "found row";
$token = $query->result_array();
echo "found token";
$this->input->set_cookie( 'session_token', $token['login_token'], time()+259200, '/', 'notyetcreated.phpfogapp.com');
echo "cookie created";
return TRUE;
} else {
echo "no beans";
return FALSE;
}
}
With the debug messages I’ve setup, after submitting the form, I get “made it back into controller attempting to login” and that’s it. Any ideas as to what could be causing it?
Change this condition in controller
You can understand more at http://ellislab.com/codeigniter/user_guide/libraries/form_validation.html