jadedknight Posted February 17, 2008 Share Posted February 17, 2008 This is my login controller for my little app I am trying to build, however, when the user submits the form and is redirect to the ‘login_user’ function, it just shows a blank page. I’d appreciate any help. (ps - it uses the codeigniter framework, but the code is very straight forward) <?php class Login extends Controller { function Login() { parent::Controller(); } function index() { $input_username = array( 'name' => 'username', 'id' => 'username', 'maxlength' => '50' ); $input_password = array( 'name' => 'password', 'id' => 'password', 'maxlength' => '50' ); $data['login_form'] = form_open('login/login_user'); $data['login_form'] .= form_input($input_username); $data['login_form'] .= form_password($input_password); $data['login_form'] .= form_submit('submit', 'Login'); $data['login_form'] .= form_close(); $this->load->view('generic/header'); $this->parser->parse('login/login', $data); $this->load->view('generic/sidebar'); $this->load->view('generic/footer'); } function login_user() { $username = $this->input->post('username', TRUE); $password = $this->input->post('password', TRUE); if (_check_login($username, $password)) { $username = $this->session->userdata('username'); redirect('/users/show_profile/' . $username); } else { redirect('/main/'); } } function _prep_password($password) { return sha1($password.$this->config->item('encryption_key')); } function _check_login($username, $password) { $this->db->where('username', $username); $this->db->where('password', $this->_prep_password($password)); $query = $this->db->get('users', 1); if ($query->num_rows() == 1) { foreach ($query->result() as $row) { $id = $row->id; $user_type = $row->user_type; $username = $row->username; } $user_data = array( 'user_id' => $id, 'user_type' => $user_type, 'username' => $username, 'logged_in' => true ); $this->session->set_userdata($user_data); return true; } return false; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/91580-login-problems-and-no-error-please-help/ Share on other sites More sharing options...
wildteen88 Posted February 17, 2008 Share Posted February 17, 2008 Do you have error_reporting set to E_ALL and is display_errors enabled? Also are you using the CodeIgnitor framework? Quote Link to comment https://forums.phpfreaks.com/topic/91580-login-problems-and-no-error-please-help/#findComment-469109 Share on other sites More sharing options...
jadedknight Posted February 17, 2008 Author Share Posted February 17, 2008 I have it so that CI reports all errors into the log at the highest level (4), I will check my .ini now. Yes it is set to E_ALL Quote Link to comment https://forums.phpfreaks.com/topic/91580-login-problems-and-no-error-please-help/#findComment-469114 Share on other sites More sharing options...
jadedknight Posted February 17, 2008 Author Share Posted February 17, 2008 Ok, I changed some more ini settings and it now is displaying the error which turns out to be: Fatal error: Call to undefined function check_login() in C:\server\www\lancefire\system\application\controllers\login.php on line 40 But if you look at the code, it is defined... Quote Link to comment https://forums.phpfreaks.com/topic/91580-login-problems-and-no-error-please-help/#findComment-469128 Share on other sites More sharing options...
Stooney Posted February 17, 2008 Share Posted February 17, 2008 No, the function in the class starts with an underscore. _check_login() so you need to change your function call. Quote Link to comment https://forums.phpfreaks.com/topic/91580-login-problems-and-no-error-please-help/#findComment-469140 Share on other sites More sharing options...
jadedknight Posted February 17, 2008 Author Share Posted February 17, 2008 It's a private function for the framework, however I tried it without an underscore and received the same results. Quote Link to comment https://forums.phpfreaks.com/topic/91580-login-problems-and-no-error-please-help/#findComment-469143 Share on other sites More sharing options...
wildteen88 Posted February 17, 2008 Share Posted February 17, 2008 Shouldn't this line (line 40): if (_check_login($username, $password)) be if ($this->_check_login($username, $password)) Quote Link to comment https://forums.phpfreaks.com/topic/91580-login-problems-and-no-error-please-help/#findComment-469157 Share on other sites More sharing options...
jadedknight Posted February 17, 2008 Author Share Posted February 17, 2008 Yep! Thanks for all the help Quote Link to comment https://forums.phpfreaks.com/topic/91580-login-problems-and-no-error-please-help/#findComment-469168 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.