codeigniter找不到md5密码

时间:2015-02-25 07:54:49

标签: php session codeigniter-2

我正在使用最新版本的Jamie Rumbelow MY_Model

下面是我创建 用户

的方法

控制器/ users.php

// add function
public function add()
    {
        $this->form_validation->set_rules($this->user->validate);

        if ($this->form_validation->run() == TRUE)
        {
            $this->user->insert($this->user_params(), TRUE);

            $this->session->set_flashdata('message', alert_info('Data berhasil disimpan'));

            redirect('users');
        }       

        $this->data['yield'] = $this->yield;

        $this->load->view($this->layout, $this->data);
    }

// user param
private function user_params()
    {
        return array( 
            'fullname' => $this->input->post('fullname') ,
            'username' => $this->input->post('username') ,
            'email' => $this->input->post('email') ,
            'password' => md5($this->input->post('password')),
            'gender' => $this->input->post('gender'),
        );
    }

我创建了创建 会话 (登录)的方法:

控制器/ sessions.php

//add function
public function add()
    {
        $this->form_validation->set_rules($this->user->rules);

        if ($this->form_validation->run() == TRUE)
        {
            $user = $this->user->get_by($this->session_params());

            if ($user)
            {
                $this->session->set_userdata('user_session', array(
                    'user_id' => $user->id,
                    'logged_in' => TRUE,
                ));

                $this->session->set_flashdata('message', alert_success('Login Berhasil !'));

                redirect('posts');
            }

            $this->session->set_flashdata('message', alert_danger('Invalid credentials, please try again'));

            redirect('sessions/add');
        }       

        $this->data['yield'] = $this->yield;

        $this->load->view($this->layout, $this->data);
    }

// session param
private function session_params()
    {

// all the post values so I didn't repeat any form insertion
        return array( 
            'username' => $this->input->post('username') ,
            'password' => md5($this->input->post('password')),
        );
    }

但我无法检索任何用户,请帮助,我错过了什么?谢谢

0 个答案:

没有答案