search
Homephp教程php手册传一个完整邮箱找回密码的功能

密码找回功能,自己看了一下还行
首先发送邮件的配置是在数据里面的,所以在发送邮件以前要读取数据库获取配置信息
public function runemail(){
$emailsys=M('sys')->where(array('sys_id'=>1))->find();
$config = array(
'MAIL_FROM'=>$emailsys['email_name'],
'MAIL_HOST'=>$emailsys['email_smtpname'],
'MAIL_USERNAME'=>$emailsys['email_emname'],
'MAIL_FROMNAME'=>$emailsys['email_rename'],
'MAIL_PASSWORD'=>$emailsys['email_pwd'],
);
C($config);//合并配置参数
$admin=M('admin')->where(array('admin_email'=>I('email')))->find();

if(!$admin){
$this->error('邮件不存在,请重新输入',0,0);
}
$oldnum=rand(10000,99999);//获取一串随机数
$num=md5($oldnum);//对随机数进行加密后传递
$emailpwd=M('admin')->where(array('admin_email'=>I('email')))->setField('admin_mdemail',$num);//更新数据库,这个时候这条记录的字段已经有了这个加密过的字符串,用来后面修改验证
$content="尊敬的用户,您好:
您当前的操作为找回密码,请点击以下链接重新设置密码
http://127.0.0.1/newadmin/index.php/Admin/Login/checkpwd/emailpwd/$num.html";
if(SendMail($_POST['email'],'找回密码服务',$content))
$this->success('邮件发送成功!,打开邮件重新设置密码',1,1);
else
$this->error('邮件发送失败',0,0);
}

这边是用到了AJAX+layer的方式提交以及返回
(这个提交方式可以参考我前面发的一个源码:http://www.thinkphp.cn/code/1521.html)

上面向邮件发送了一段链接,传递了一个加密过的字符串
接下来是打开修改密码的页面
//打开修改密码页面
public function checkpwd(){
$admin_mdemail=I('emailpwd');
$this->assign('admin_mdemail',$admin_mdemail);
$this->display();
}
这边向修改密码页面传递了这个加密的字符串,模板那边用隐藏文本框来存值
最后就是修改密码的操作了
//修改密码操作
public function runcheckpwd(){
$admin_mdemail=I('admin_mdemail');//获取加密过后的随机值
$admin_pwd=I('admin_pwd','','md5');//获取新密码,并且加密
$checkadmin=M('admin')->where(array('admin_mdemail'=>$admin_mdemail))->find();//验证用户是否存在
if(!$checkadmin){
$this->error('邮箱不存在,请重新输入',0,0);
}else{
$admin=M('admin')->where(array('admin_mdemail'=>$admin_mdemail))->setField('admin_pwd',$admin_pwd);
$this->success('恭喜您,密码修改成功',U('login'),1);
}

}


就先这样吧,如果要源码的话 可以先加我QQ:876902658
做差不多了再做更新指定地点了

贴一下操作步骤图
传一个完整邮箱找回密码的功能传一个完整邮箱找回密码的功能传一个完整邮箱找回密码的功能传一个完整邮箱找回密码的功能传一个完整邮箱找回密码的功能

AD:真正免费,域名+虚机+企业邮箱=0元

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.