Jump to content

Login Problems.. and no error? Please help :)


jadedknight

Recommended Posts

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;
    }
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/91580-login-problems-and-no-error-please-help/
Share on other sites

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.