Welcome Guest, Not a member yet? Register   Sign In
Problems validating log in when md5 is used, help!
#1

[eluser]mindSmile[/eluser]
It's my first time posting here and I'm pretty new to CI. I've been working on a simple log in form that will redirect to a members area once the entered username and password are matched to a pair in the database.

Here's the model:
Code:
<?php

class Members_model extends Model{

    function validate()
    {
        $this->db->where('username', $this->input->post('username'));
        $this->db->where('password', md5($this->input->post('password')));
        $query = $this->db->get('members');
        
        if($query->num_rows == 1)
        {
            return true;
        }
    }
    function create_account(){
        $new_member_insert_data = array(
            'username' => $this->input->post('username'),
            'email' => $this->input->post('email'),
            'password' => md5($this->input->post('password'))
        );
        
        $insert = $this->db->insert('members', $new_member_insert_data);
        return $insert;
    }

}

And here's the relevant part of the controller:
Code:
<?php

class Login extends Controller {function validate_credentials(){
        
        $this->load->model('members_model');
        $query = $this->members_model->validate();
        
        if($query){
            $data = array(
                'username' => $this->input->post('username'),
                'is_logged_in' => true
            );
            $this->session->set_userdata($data);
            redirect('members/index');
        }    else    {
            echo 'Incorrect! Sorry!';
            $this->index();
        }

    }

If I take away the md5 it will log in fine (with an unencrypted password both at creation and at login). And I've tried both inserting the record into the database in phpMyAdmin and selecting the md5 function as well as entering the info into the sign up form. If anyone sees why the md5 is making me unable to log in, please let me know. I've already mentally and emotionally prepared myself to be told I'm missing one itsy bitsy little thing and feel silly for pulling my hair out. Appreciate any help! Thanks!


Messages In This Thread
Problems validating log in when md5 is used, help! - by El Forum - 05-25-2010, 03:28 AM
Problems validating log in when md5 is used, help! - by El Forum - 05-25-2010, 03:43 AM
Problems validating log in when md5 is used, help! - by El Forum - 05-25-2010, 03:49 AM
Problems validating log in when md5 is used, help! - by El Forum - 05-26-2010, 04:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB