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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.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 Codeigniter消息:调用未定义的函数random_string()_Php_Codeigniter - Fatal编程技术网

Php Codeigniter消息:调用未定义的函数random_string()

Php Codeigniter消息:调用未定义的函数random_string(),php,codeigniter,Php,Codeigniter,我遇到了以下错误:遇到了一个未捕获的异常 类型:错误 消息:调用未定义函数random_string() 文件名:C:\xampp\htdocs\HerbalCebu\application\controllers\login.php 行号:128 回溯: 文件:C:\xampp\htdocs\HerbalCebu\index.php行:315函数: 需要你一次 当我想要生成一个随机字符串时,它将作为用户的临时密码放置在其中 这是我的控制器 function forgot_password()

我遇到了以下错误:遇到了一个未捕获的异常

类型:错误

消息:调用未定义函数random_string()

文件名:C:\xampp\htdocs\HerbalCebu\application\controllers\login.php

行号:128

回溯:

文件:C:\xampp\htdocs\HerbalCebu\index.php行:315函数: 需要你一次

当我想要生成一个随机字符串时,它将作为用户的临时密码放置在其中

这是我的控制器

function forgot_password()
            {
            $this->form_validation->set_rules('emailpass', 'emailpass', 'trim|required');

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

            $this->load->view('Login/modal_forgot');
            $this->load->view('CustTemplate/header');
            $this->load->view('Login/Login');
            $this->load->view('CustTemplate/footer');
            }else{
            $password = ('alpha', 8);
            $data = array('password'=>md5($password));
            $this->db->where('email',$this->input->post('emailpass'));

            $this->db->update('users',$data);
            $this->session->set_flashdata('message','here is your new password: <mark>'.$password.'</mark><br> please login now and change the given password');
            redirect(base_url('login'));
            }
            }

            public function check_email($password)
            {
                $email = $this->input->post('emailpass');

                $result = $this->queries_login->get_email($email);

                if($result)
                {
                    return TRUE;
                }
                else
                {
                    $this->form_validation->set_message('Check_email','The email you entered is not on the database');
                    return FALSE;
                }
            }

我在代码中的任何地方都看不到它的使用(可能在这里:
$password=('alpha',8);
?),但是您应该在通过
$this->load->helper('string')调用函数之前加载helper
或在
application/config/autoload.php中自动加载

如果错误仍然存在,请确保文件存在于
system/helpers/string\u helper.php


每当有人使用
md5
时,人们总是建议您不要使用它(甚至在官方文档中也建议您这样做):


您可以将
password\u hash
函数verify与
password\u verify
一起使用

您是否加载了字符串帮助程序?您最好在控制器的_构造区域加载帮助程序。不要再次将md5用于密码非常不安全,不适合用于密码
public function get_email($email)
        {
            $this->db->select('*');
            $this->db->from('users');
            $this->db->where('email',$email);
            $this->db->limit(1);

            $query = $this->db->get();

            if($query ->num_rows()==1)
            {
                return $query->result();
            }
            else
            {
                return false;
            }
        }