gpt4 book ai didi

php - Codeigniter 消息 : Call to undefined function random_string()

转载 作者:行者123 更新时间:2023-12-03 20:16:32 27 4
gpt4 key购买 nike

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

Type: Error

Message: Call to undefined function random_string()

Filename: C:\xampp\htdocs\HerbalCebu\application\controllers\login.php

Line Number: 128

Backtrace:

File: C:\xampp\htdocs\HerbalCebu\index.php Line: 315 Function: require_once,



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

这是我的 Controller
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;
}
}

和模型
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;
}
}

最佳答案

我并没有真正看到它在您的代码中的任何地方使用(可能在这里:$password = ('alpha', 8); ?),但是您应该在通过 $this->load->helper('string'); 调用函数之前加载帮助程序或自动加载到 application/config/autoload.php
如果错误仍然存​​在,请确保文件存在于 system/helpers/string_helper.php .

正如有人使用 md5 时不断建议的那样- 你真的不应该使用它(甚至在官方文档中推荐):http://php.net/manual/en/function.md5.php

您可以使用 password_hash功能验证 password_verify . http://php.net/manual/en/function.password-hash.php

关于php - Codeigniter 消息 : Call to undefined function random_string(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49093611/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com