Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无法使用md5密码登录codeigniter?_Php_Codeigniter_Passwords_Md5 - Fatal编程技术网

Php 无法使用md5密码登录codeigniter?

Php 无法使用md5密码登录codeigniter?,php,codeigniter,passwords,md5,Php,Codeigniter,Passwords,Md5,我无法登录用户。我使用md5方法在数据库中保存了加密密码。现在,当我输入电子邮件和密码与登录的形式,它是不工作的用户不能登录与md5密码 我已经尝试使用sha1密码,但它不起作用 控制器功能 public function userlogin() { $checkformval = $this->input->post('checkformval'); if ($checkformval == "1") {

我无法登录用户。我使用md5方法在数据库中保存了加密密码。现在,当我输入电子邮件和密码与登录的形式,它是不工作的用户不能登录与md5密码

我已经尝试使用sha1密码,但它不起作用

控制器功能

     public function userlogin()
    {


        $checkformval = $this->input->post('checkformval');

        if ($checkformval == "1") {

            //set validation rules
            $this->form_validation->set_rules('emailphone', 'Email', ['required']);
            $this->form_validation->set_rules('password', 'Password', ['required']);


            //run validation check
            if ($this->form_validation->run() == FALSE) {   //validation fails
                $errors = validation_errors();
                echo json_encode(['loginerror' => $errors]);
            } else {

                $signin_data = $this->db->get_where('user', array(
                    'email' => $this->input->post('emailphone'),
                    'password' => md5($this->input->post('password')),
                    //'is_active' => '1'
                ));

                if ($signin_data->num_rows() > 0) {
                    foreach ($signin_data->result_array() as $row) {
                        $this->session->set_userdata('user_login', 'yes');
                        $this->session->set_userdata('user_id', $row['user_id']);
                        $this->session->set_userdata('user_name', $row['name']);
                        $this->session->set_userdata('social_user_provider', $row['oauth_provider']);
                        $this->session->set_userdata('user_profile_picture', $row['upload_pic']);
                        $this->session->set_userdata('gmail_profile_picture', $row['picture_url']);
                        //$this->session->set_userdata('set_pin_code', $row['set_pin_code']);
                        $this->session->set_userdata('name', $row['name']);
                        setcookie ("loginEmail", $row['email'], time()+ (10 * 365 * 24 * 60 * 60));
                        setcookie ("loginPass", $row['password'],  time()+ (10 * 365 * 24 * 60 * 60));


                        if ($row['is_active'] == '0') {
                            echo json_encode(['accountnotactive' => 'Your account is not active yet.']);
                            //echo json_encode(['currentuseractivecode' => $row['activation_code']]);
                        }
                       /* else if ($row['set_pin_code'] == "") {
                            echo json_encode(['pincodeempty' => 'Your Pin Code Is Empty']);
                        }*/
                        else if ($row['is_active'] == '1') {
                            echo json_encode(['loginsuccess' => 'Congratulations! You have successfully logged into the system.
']);
                        }

                    }

                } else {
                    echo json_encode(['loginerror' => 'Whoops! Your attempt to log in failed. Try again!']);
                }



            }
        }
        else
        {
            redirect('/');
        }

    }

您真的不应该使用
md5
sha1
作为密码,现代硬件可以很容易地强制使用它们。PHP有。您还应该避免将密码(哈希或非哈希)存储在cookie中。如果你想创建一些“记住我”的函数,或者不管是什么原因,你都应该仔细阅读实现它的安全方法;当你处理安全问题(比如处理密码等)时,不要试图自己解决。经常做广泛的研究,看看手册上说了些什么。例如,手册明确警告您不要将其用于密码哈希。安全是一项艰巨而复杂的任务。如果您尝试推出自己的解决方案,而不是遵循最佳实践(有很多指南),那么几乎可以肯定的是,您的解决方案不会像您认为的那样安全。您必须确保用户凭据的安全。