首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何修复PHP codeigniter框架中的"Undefined property: Register::$encrypt“

如何修复PHP codeigniter框架中的"Undefined property: Register::$encrypt“
EN

Stack Overflow用户
提问于 2019-05-17 02:36:47
回答 1查看 3.2K关注 0票数 1

当我在CodeIgniter中提交表单时,我收到这个错误消息:未定义的属性: Register::$encrypt。我想要散列密码,这就是我使用加密的原因。

我曾尝试在autoload.php中包含加密库,但还是弹出了另一个错误。

这就是错误弹出的地方。

函数验证(){

代码语言:javascript
复制
    $this->form_validation->set_rules('user_name','Name','required|trim');
    $this->form_validation->set_rules('user_email','Email Address','required|trim|valid_email|is_unique[codeigniter_register.email]');
    $this->form_validation->set_rules('user_password','Password','required|trim');

    if($this->form_validation->run()){

        $verification_key=md5(rand());
        $encrypted_password = $this->encrypt->encode($this->input->post('user_password'));
        $data = array(
            'name' => $this->input->post('user_name'),
            'email' => $this->input->post('user_email'),
            'password' => $encrypted_password,
            'verification_key' => $verification_key


        );
        $id=$this->register_model->insert($data);
        if($id > 0){
            $subject='Please verify email for login';
            $message="
                <p>Hi".$this->input->post('user_name')."</p>
                <p>Verify your email for login to this system. Click this <a href='".base_url()."register/verify_email/".$verification_key."'>link</a>.</p>
                <p>Use this link to log in in to this system.</p>
                <p>Thanks You.</p>
            ";

            $config = array(
                'protocol' => 'smtp',
                'smtp_host' => 'smtpout.secureserver.net',
                'smtp_port' => 80,
                'smtp_user' => 'root',
                'smtp_pass' => 'root',
                'mailtype' => 'html',
                'charset' => 'iso-8859-1',
                'wordwrap' =>TRUE
            );

            $this->load->library('email',$config);
            $this->email->set_newline("\r\n");
            $this->email->from('info@icode.info');
            $this->email->to($this->input->post('user_email'));
            $this->email->subject($subject);
            $this->email->message($message);
            if($this->email->send()){
                $this->session->set_flashdata('message','Check in your email for verification mail');
                redirect('register');
            }

        }

    }
    else{
        $this->index();
    }

我希望在提交表单后发出警报或将我填写的数据发送到数据库,

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56174702

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档