php 注册登录,邮件确认激活
2019独角兽企业重金招聘Python工程师标准>>>
登陆、注册界面
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="no-js ie6 lt8"> <![endif]-->
<!--[if IE 7 ]> <html class="no-js ie7 lt8"> <![endif]-->
<!--[if IE 8 ]> <html class="no-js ie8 lt8"> <![endif]-->
<!--[if IE 9 ]> <html class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html> <!--<![endif]--><head><meta charset="UTF-8" /><!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> --><title>Login and Registration Form with HTML5 and CSS3</title><meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="Login and Registration Form with HTML5 and CSS3" /><meta name="keywords" content="html5, css3, form, switch, animation, :target, pseudo-class" /><meta name="author" content="Codrops" /><link rel="shortcut icon" href="../favicon.ico"> <link rel="stylesheet" type="text/css" href="css/demo.css" /><link rel="stylesheet" type="text/css" href="css/style.css" /><link rel="stylesheet" type="text/css" href="css/animate-custom.css" /></head><body><div><header><h1>It's IMOOC<span>This Is King Show Time</span></h1><nav><span>Click <strong>"Join us"</strong> to Register the Imooc</span></nav></header><section> <div id="container_demo" ><a id="toregister"></a><a id="tologin"></a><div id="wrapper"><div id="login" class="animate form"><form action="doAction.php?act=login" autocomplete="on" method="post"> <h1>Log in</h1> <p> <label for="username" data-icon="u" > Your username </label><input id="username" name="username" required="required" type="text" placeholder="My Username"/></p><p> <label for="password" data-icon="p"> Your password </label><input id="password" name="password" required="required" type="password" placeholder="*****" /> </p><p> <input type="checkbox" name="loginkeeping" id="loginkeeping" value="loginkeeping" /> <label for="loginkeeping">Keep me logged in</label></p><p class="login button"> <input type="submit" value="Login" /> </p><p>Not a member yet ?<a href="#toregister">Join us</a></p></form></div><div id="register" class="animate form"><form action="doAction.php?act=reg" autocomplete="on" method="post"> <h1> Sign up </h1> <p> <label for="usernamesignup" data-icon="u">Your username</label><input id="usernamesignup" name="username" required="required" type="text" placeholder="Mr.King" /></p><p> <label for="emailsignup" data-icon="e" > Your email</label><input id="emailsignup" name="email" required="required" type="email" placeholder="Mr.King@mail.com"/> </p><p> <label for="passwordsignup" data-icon="p">Your password </label><input id="passwordsignup" name="password" required="required" type="password" placeholder="******"/></p><p class="signin button"> <input type="submit" value="Sign up"/> </p><p> Already a member ?<a href="#tologin"> Go and log in </a></p></form></div></div></div> </section></div></body>
</html>
php代码
<?php
header('content-type:text/html;charset=utf-8');
//1.包含所需文件
error_reporting(0);
require_once 'swiftmailer-master/lib/swift_required.php';
require_once 'PdoMySQL.class.php';
require_once 'config.php';
require_once 'pwd.php';
//2.接收信息
$act=$_GET['act'];
$username=addslashes($_POST['username']);
$password=md5($_POST['password']);
$email=$_POST['email'];
$table='user';
//3.得到连接对象
$PdoMySQL=new PdoMySQL();
if($act==='reg'){$regtime=time();//完成注册的功能$token=md5($username.$password.$regtime);$token_exptime=$regtime+24*3600;//过期时间$data=compact('username','password','email','token','token_exptime','regtime');$res=$PdoMySQL->add($data, $table);$lastInsertId=$PdoMySQL->getLastInsertId();if($res){//发送邮件,以QQ邮箱为例//配置邮件服务器,得到传输对象$transport=Swift_SmtpTransport::newInstance('smtp.qq.com',25);//设置登陆帐号和密码$transport->setUsername('704568245@qq.com');$transport->setPassword($emailPassword);//得到发送邮件对象Swift_Mailer对象$mailer=Swift_Mailer::newInstance($transport);//得到邮件信息对象$message=Swift_Message::newInstance();//设置管理员的信息$message->setFrom(array('704568245@qq.com'=>'动物管理系统'));//将邮件发给谁$message->setTo(array($email=>'感谢你注册宠物系统'));//设置邮件主题$message->setSubject('激活邮件');$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?act=active&token={$token}";$urlencode=urlencode($url);$str=<<<EOF亲爱的{$username}您好~!感谢您注册我们网站<br/>请点击此链接激活帐号即可登陆!<br/><a href="{$url}">{$urlencode}</a><br/>如果点此链接无反映,可以将其复制到浏览器中来执行,链接的有效时间为24小时。
EOF;$message->setBody("{$str}",'text/html','utf-8');try{if($mailer->send($message)){echo "恭喜您{$username}注册成功,请到邮箱激活之后登陆<br/>";echo '3秒钟后跳转到登陆页面';echo '<meta http-equiv="refresh" content="3;url=index.php#tologin"/>';}else{$PdoMySQL->delete($table,'id='.$lastInsertId);echo '注册失败,请重新注册';echo '3秒钟后跳转到注册页面';echo '<meta http-equiv="refresh" content="3;url=index.php#toregister"/>';}}catch(Swift_ConnectionException $e){echo '邮件发送错误'.$e->getMessage();}}else{echo '用户注册失败,3秒钟后跳转到注册页面';echo '<meta http-equiv="refresh" content="3;url=index.php#toregister"/>';}
}elseif($act==='login'){//完成登陆的功能$row=$PdoMySQL->find($table,"username='{$username}' AND password='{$password}'",'status');if($row['status']==0){echo '请先激活再登陆';echo '<meta http-equiv="refresh" content="3;url=index.php#tologin"/>';}else{echo '登陆成功,3秒钟后跳转到首页';echo '<meta http-equiv="refresh" content="3;url=http://www.imooc.com"/>';}}elseif($act==='active'){$token=addslashes($_GET['token']);$row=$PdoMySQL->find($table,"token='{$token}' AND status=0",array('id','token_exptime'));$now=time();if($now>$row['token_exptime']){echo '激活时间过期,请重新登陆激活';}else{$res=$PdoMySQL->update(array('status'=>1),$table,'id='.$row['id']);if($res){echo '激活成功,3秒钟后跳转到登陆页面';echo '<meta http-equiv="refresh" content="3;url=index.php#tologin"/>';}else{echo '激活失败,请重新激活';echo '<meta http-equiv="refresh" content="3;url=index.php"/>';}}}
<?php/** This file is part of SwiftMailer.* (c) 2004-2009 Chris Corbyn** For the full copyright and license information, please view the LICENSE* file that was distributed with this source code.*//** Autoloader and dependency injection initialization for Swift Mailer.*/if (class_exists('Swift', false)) {return;
}// Load Swift utility class
require dirname(__FILE__) . '/classes/Swift.php';if (!function_exists('_swiftmailer_init')) {function _swiftmailer_init(){require dirname(__FILE__) . '/swift_init.php';}
}// Start the autoloader and lazy-load the init script to set up dependency injection
Swift::registerAutoload('_swiftmailer_init');
其中在进行mysql数据表删除数据的时候没想到delete table 会在日志中有记录,占用空间
后来想到用truncate
删除数据,且不残留记录
-- 清空全部数据,不写日志,不可恢复,速度极快
truncate
table
表名;
-- 清空全部数据,写日志,数据可恢复,速度慢
delete
from
表名
转载于:https://my.oschina.net/u/1778933/blog/469583
php 注册登录,邮件确认激活相关推荐
- 1、登录——邮件发送激活链接
我们在这里输入账号.密码.邮箱后,后端的service层会判断账号.邮箱是否已被注册.如果没有,则会向邮箱中发送激活链接 在我们点击注册按钮之后,在service层中存入数据库,然后通过数据库中用户的 ...
- 注册页面邮件发送激活码
接上一篇的点击注册按钮实现注册功能用户注册例题,当我们点击注册时,自动发送邮件给我注册的email账号里面,发送的是激活码: 直接在UserServiceImpl的register方法里面写发送邮件代 ...
- Java注册登录及邮箱发送账号激活(主要技术栈SpringBoot,MyBatis)
文章目录 前言 学习之前需要掌握的知识 项目环境搭建 数据库的搭建 前端页面的搭建 后端代码 格式 pojo mapper Controller service 最后 前言 项目流程图如下: 这里我们 ...
- iOS登录注册登录界面(UITextField)
登录功能是我在湖畔做的第一个需求. 当时PD给我的草图和下图类似: (图片来自知乎iOS客户端登录界面) 不过需求中要求用户名或者密码错误时,输入框要抖动(类似Mac登录密码错误的抖动效果). 如果实 ...
- 【教程】Unity账号注册和Unity Hub激活
Unity账号注册 首先我们先进入unity的官网. 点击官网登录头像按钮,创建Unity ID. 3.填写相应的信息,填写完毕后先进行人机身份验证,最后点击立即注册. 4.打开我们对应的邮箱进行邮件 ...
- APP注册登录那点事
转载地址:http://www.woshipm.com/pd/206667.html?utm_source=tuicool APP注册登录那点事 2015/09/21 阅读 3.2万 评论 6 收藏 ...
- Django+bootstrap+注册登录系统
转自:https://www.cnblogs.com/robindong/p/9610057.html Robin_D 博客园 首页 新随笔 联系 订阅 管理 随笔 - 10 文章 - 0 评论 ...
- 64位游戏找call_《使命召唤16:战区》配置注册登录全攻略,三步让你极迅游戏!...
如果说谁是2020年最火的游戏,那么<使命召唤16:战区>绝对是排名第一.自从<使命召唤16:战区>发布之后,同时在线人数就不断刷新纪录,一天300万,3天800万 ,到现在已 ...
- Jsp+Servlet+MYSQL注册登录案例(界面难看,ε=(´ο`*)))唉)
注册登录界面尤为常见,我的界面尤为难看,勉为其难的写吧,前端不熟就是这样... 这个案例运用到了: 1.Jsp动态页面--->动态页面 2.Servlet逻辑判断后台---->实现界面与数 ...
最新文章
- R语言stringr包str_ends函数、str_starts函数起始、结束字符串判断实战
- java 异步事件_处理异步事件的三种方式
- 网站推广专员浅析网站推广期间如何防止关键词出现下降情况?
- 两字典(dict)组合(重复键进行加法)一行命令实现Python
- MySQL从入门到精通50讲(八)-MySQL排序分组
- MyBatis中动态sql实现传递多个参数并使用if进行参数的判断和实现like模糊搜索以及foreach实现in集合
- 双向链表简单实现及图示
- colab清理gpu缓存_安卓手机为什么会变卡?强制GPU渲染手机就能变流畅?你真的懂吗...
- pico park无法连接至远程服务器,pico park怎么联机玩?pico park怎么邀请朋友一起玩?[多图]...
- 动态切换view视图viewflipper组件
- 新技能Get:如何利用HTTP技术提升网页的加载速度
- nginx模块nginx_upstream_check_module来检查后端服务器的健康情况
- 计算机运行命令定时关机,电脑定时关机命令 使用系统命令定时关机 - 云骑士一键重装系统...
- oracle中ipad是什么意思,Oracle中Ipad和Rpad函数的用法
- MAX30102 模拟IIC读取程序(C语言)
- 句法结构解析和Transition_based方法
- 怎样做风险评估?风险评估有哪些具体实施流程?
- 深入理解PHP原理之PHP与WEB服务器交互
- 办理icp许可证对经营范围还有要求吗
- 【Python学习笔记(二)】使用Pyinstaller将不同路径下的py文件打包成exe可执行文件