在php codeigniter中重置密码功能

我正在尝试在codeigniter PHP中编写重置密码功能,并介意不要点击从哪里开始,这是最好的方法,请帮助

my db as like this
CREATE TABLE `members` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `username` varchar(255) NOT NULL,
 `email` varchar(255) NOT NULL,
 `password` varchar(255) NOT NULL,
 `verifystring` varchar(15) NOT NULL,
 `lostkey` varchar(100) NOT NULL,
 `active` enum('0','1') NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1

功能是这样的

//忘记密码

 public function forget_password(){

    $this->form_validation->set_rules('email','Email Address','xss_clean|required|valid_email|callback_reset_password');
    if($this->form_validation->run() == FALSE){
    $this->load->view('account/forget_password');
    }else{

        //send an email
        $this->load->library('email');
        $this->email->set_newline("\r\n");

            $this->email->from('me@gmail.com', 'Raju');
            $this->email->to('me@gmail.com');
            $this->email->subject('Email my');
            $key = 12334455;
            $message = "Please click this url to change your password ". base_url()."reset_Now/".$key ;
            $message .="<br/>Thank you very much";
            $this->email->message($message);

        if($this->email->send())
                {
                    echo 'Please check your email to reset password.';
                }

                else
                {
                    show_error($this->email->print_debugger());
                }
    }

}


//email check for forget password
function reset_password($email){
    $query = $this->db->get_where('members', array('email'=>$email));

    if(!$query->num_rows()>0){
        $this->form_validation->set_message('forget_email_check', 'The %s does not exists in our database');
        return FALSE;
    }else{

        //check database fields
        /*
        $this->db->where('email', $email);
        $this->db->limit(1);
        $Q = $this->db->get('members');
        if($Q->num_rows()>0){
            $data = $Q->result_array();

            echo $data[0]['username'].'<br/>';
            echo $data[0]['password'].'<br/>';
        }

    */

        echo '<br/>'. $email.'<br/>';
    }

    //$query->free_result();
    //return true;
}

解决方法:

这很简单.首先要求用户输入他们的用户名或ID或电子邮件或其登录凭据. (当然不是密码).现在使用该值,查询数据库,如果值存在,只需检索相应的电子邮件地址. (如果登录凭据是电子邮件,则只需检查数据库中是否存在电子邮件地址).然后,

>创建一个随机字符串
>从数据库中检索用户的电子邮件,并将此新创建的字符串发送到用户的电子邮件ID.
>更新数据库用户的当前密码.
>现在,设置一个标志,当用户使用自动生成的密码登录时,该标志基本上会提示用户创建新密码.
>用户创建新密码后,再更新数据库中的密码并更新标志.

从现在开始,只要用户登录,您的应用程序就不会提示用户重置用户密码.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...