清華大佬耗費三個月吐血整理的幾百G的資源,免費分享!....>>>
num、password、name、email、addtime、status
<?php namespace Home\Controller; use Think\Controller; class LoginController extends Controller { //處理登錄 public function signin(){ if(IS_GET){ $this->display(); } if(IS_POST){ /* 調用登錄接口登錄 */ $User = M('user') ; //I方法接收頁面傳遞來的值 $num = I('num') ; $password = I('password') ; //查找user表中num等于$num的值 $datanum = $User->where(array('num'=>$num))->find(); //判斷$datanum的值 if ($datanum){ if (md5($password) === $datanum['password']) { if ($datanum['status'] == 0) { $this->error('用戶處于未審核狀態,請聯系管理員'); }elseif($datanum['status'] == 2){ $this->error('用戶處于禁用狀態,請聯系管理員'); }else{ $this->autoLogin($datanum) ; //調用私有方法自動登錄. $uid = $datanum['id']; if($_SESSION['user_auth']['uid'] && $_SESSION['user_auth']['role'] == 'user'){ $this->success('登錄成功!', U('Index/index')); }else{ $this->error('存儲錯誤.'); } } }else{ $this->error('密碼填寫不正確,請重新填寫'); exit(); } }else{ $this->error('用戶不存在,請注冊',U('signup')); } } } public function autoLogin($user){ /* 記錄登錄SESSION */ $auth = array( 'uid' => $user['id'], 'num' => $user['num'], 'role' => 'user' , //記錄用戶類型 ); session('user_auth', $auth); session('user_auth_sign', data_auth_sign($auth)); } /* * 用戶注冊 */ public function signup(){ if(is_user_login()){ $this->redirect('Index/index'); } if(IS_GET){ //注冊頁面 $this->display(); } if(IS_POST){ //判斷用戶 $data['num'] = I('num') ; $User = M('user') ; $datanum = $User->where($data)->find(); if ($datanum){ $this->success('您已經注冊過,請直接登錄',U('signin')); }else{ $data['password'] = md5(I('password')); $data['name'] = I('name'); $data['email'] = I('email'); $data['addtime'] = time(); $uid = $User->add($data); if($uid) $this->success('注冊成功',U('signin')) ; else $this->error('注冊失敗') ; } } } public function logout(){ if(is_user_login()){ $User = M('user') ; session('user_auth', null); session('user_auth_sign', null); session('[destroy]'); $this->success('登出成功!', U('signin')); } else { $this->redirect('signin'); } } //忘記密碼 public function wjpas(){ if(IS_GET){ $this->display(); } if(IS_POST){ $User = M('user') ; $num = I('num') ; $data['password'] = md5(I('password')) ; $email = I('email') ; $datanum = $User->where(array('num'=>$num))->find(); if ($datanum){ if ($email === $datanum['email']) { $User->where(array('num'=>$num))->save($data); // 根據條件更新記錄 $this->success('密碼修改成功',U('signin')) ; }else{ $this->error('郵箱填寫不正確,請重新填寫'); exit(); } }else{ $this->error('用戶不存在,請注冊',U('signup')); } } } } ?>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Bootstrap Admin</title> <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <link rel="stylesheet" type="text/css" href="__PUBLIC__/bootstrap/css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="__PUBLIC__/stylesheets/theme.css"> <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.css"> <script src="__PUBLIC__/jquery-1.8.1.min.js" type="text/javascript"></script> <script type="text/javascript" src="__PUBLIC__/layer/layer.min.js"></script> <script src="__PUBLIC__/bootstrap/js/bootstrap.js"></script> <script type="text/javascript" src='__PUBLIC__/layer/extend/layer.ext.js'></script> <!-- Demo page code --> <style type="text/css"> #line-chart { height:300px; width:800px; margin: 0px auto; margin-top: 1em; } .brand { font-family: georgia, serif; } .brand .first { color: #ccc; font-style: italic; } .brand .second { color: #fff; font-weight: bold; } </style> <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- Le fav and touch icons --> <link rel="shortcut icon" href="__PUBLIC__/assets/ico/favicon.ico"> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="__PUBLIC__/assets/ico/apple-touch-icon-144-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="__PUBLIC__/assets/ico/apple-touch-icon-114-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="__PUBLIC__/assets/ico/apple-touch-icon-72-precomposed.png"> <link rel="apple-touch-icon-precomposed" href="__PUBLIC__/assets/ico/apple-touch-icon-57-precomposed.png"> </head> <!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]--> <!--[if IE 7 ]> <body class="ie ie7"> <![endif]--> <!--[if IE 8 ]> <body class="ie ie8"> <![endif]--> <!--[if IE 9 ]> <body class="ie ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <body> <!--<![endif]--> <div class="navbar"> <div class="navbar-inner"> <div class="container-fluid"> <ul class="nav pull-right"> </ul> <a class="brand" href=""><span class="first">CSV</span> <span class="second"> drawing tool</span></a> </div> </div> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="dialog span4"> <div class="block"> <div class="block-heading">登錄</div> <div class="block-body"> <form name="signin" id="form1" method="post" action="{:U('Login/signin')}"> <label>工號</label> <input type="text" class="span12" name="num" value="" id="num"> <label>密碼</label> <input type="password" class="span12" name="password" value="" id="psw"> <button type="submit" target-form="form1" class="am-btn am-btn-primary am-btn-block ajax-post" style="display:none;">提交</button> <button type="button" onclick="sub(this.form,this)" class="btn btn-primary pull-right" >登錄</button> <label class="remember-me"><input type="checkbox"> 記住我</label> <div class="clearfix"></div> </form> </div> </div> <p class="pull-right" style=""><a href="{:U('Login/signup')}" target="_blank">注冊</a></p> <p><a href="{:U('Login/wjpas')}" target="_blank">忘記密碼?</a></p> </div> </div> <script type="text/javascript" src="__PUBLIC__/Js/login.js"></script> <script type="text/javascript"> function sub(o){ //表單驗證部分 if($("#num").val() == ""){ layer.alert('工號不能為空') ; $("#num").focus(); return false ; } if($("#psw").val() == ""){ layer.alert('密碼不能為空') ; $("#psw").focus(); return false ; } $(".ajax-post").trigger('click') ; } </script> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Bootstrap Admin</title> <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <link rel="stylesheet" type="text/css" href="__PUBLIC__/bootstrap/css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="__PUBLIC__/stylesheets/theme.css"> <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.css"> <script src="__PUBLIC__/jquery-1.8.1.min.js" type="text/javascript"></script> <script type="text/javascript" src="__PUBLIC__/layer/layer.min.js"></script> <script src="__PUBLIC__/bootstrap/js/bootstrap.js"></script> <script type="text/javascript" src='__PUBLIC__/layer/extend/layer.ext.js'></script> <!-- Demo page code --> <style type="text/css"> #line-chart { height:300px; width:800px; margin: 0px auto; margin-top: 1em; } .brand { font-family: georgia, serif; } .brand .first { color: #ccc; font-style: italic; } .brand .second { color: #fff; font-weight: bold; } .block-heading font{ font-weight: lighter; margin-left: 10px; font-size: 13px; color: #0088cc; font-family: serif; } </style> <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- Le fav and touch icons --> <link rel="shortcut icon" href="__PUBLIC__/assets/ico/favicon.ico"> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="__PUBLIC__/assets/ico/apple-touch-icon-144-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="__PUBLIC__/assets/ico/apple-touch-icon-114-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="__PUBLIC__/assets/ico/apple-touch-icon-72-precomposed.png"> <link rel="apple-touch-icon-precomposed" href="__PUBLIC__/assets/ico/apple-touch-icon-57-precomposed.png"> </head> <!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]--> <!--[if IE 7 ]> <body class="ie ie7"> <![endif]--> <!--[if IE 8 ]> <body class="ie ie8"> <![endif]--> <!--[if IE 9 ]> <body class="ie ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <body> <!--<![endif]--> <div class="navbar"> <div class="navbar-inner"> <div class="container-fluid"> <ul class="nav pull-right"> </ul> <a class="brand" href=""><span class="first">CSV</span> <span class="second"> drawing tool</span></a> </div> </div> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="span4 offset4 dialog"> <div class="block"> <div class="block-heading">注冊<font>帶*的為必填項</font></div> <div class="block-body"> <form name="signup" id="form1" method="post" action="{:U('Login/signup')}"> <label>*工號</label> <input type="text" class="span12" name="num" value="" id="num"> <label>*姓名</label> <input type="text" class="span12" name='name' value="" id="name"> <label>*郵箱</label> <input type="text" class="span12" name="email" value="" id="email"> <label>*密碼</label> <input type="password" class="span12" name="password" value="" id="psw"> <button type="submit" target-form="form1" class="am-btn am-btn-primary am-btn-block ajax-post" style="display:none;">提交</button> <button type="button" onclick="sub(this.form,this)"class="btn btn-primary pull-right" >注冊</button> <!-- <a href="" class="btn btn-primary pull-right">注冊</a> --> <label class="remember-me"><input type="checkbox"> 我同意<a href="terms-and-conditions.html">該網站使用協議</a></label> <div class="clearfix"></div> </form> </div> </div> <p><a href="{:U('Login/signin')}">已注冊過,立即登錄</a></p> </div> </div> <script type="text/javascript" src="__PUBLIC__/Js/login.js"></script> <script type="text/javascript"> function sub(o){ if($("#num").val() == ""){ layer.alert('工號不能為空') ; $("#num").focus(); return false ; } if($("#name").val() == ""){ layer.alert('姓名不能為空') ; $("#name").focus(); return false ; } if ($("#email").val() == "") { layer.alert('郵箱不能為空') ; $("#email").focus(); return false ; } if (!$("#email").val().match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)) { layer.alert("郵箱格式不正確"); $("#email").focus(); return false; } if($("#psw").val() == ""){ layer.alert('密碼不能為空') ; $("#psw").focus(); return false ; } //表單驗證部分 $(".ajax-post").trigger('click') ; } </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Bootstrap Admin</title> <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <link rel="stylesheet" type="text/css" href="__PUBLIC__/bootstrap/css/bootstrap.css"> <link rel="stylesheet" type="text/css" href="__PUBLIC__/stylesheets/theme.css"> <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.css"> <script src="__PUBLIC__/jquery-1.8.1.min.js" type="text/javascript"></script> <script type="text/javascript" src="__PUBLIC__/layer/layer.min.js"></script> <script src="__PUBLIC__/bootstrap/js/bootstrap.js"></script> <script type="text/javascript" src='__PUBLIC__/layer/extend/layer.ext.js'></script> <!-- Demo page code --> <style type="text/css"> #line-chart { height:300px; width:800px; margin: 0px auto; margin-top: 1em; } .brand { font-family: georgia, serif; } .brand .first { color: #ccc; font-style: italic; } .brand .second { color: #fff; font-weight: bold; } .block-heading font{ font-weight: lighter; font-size: 13px; color: #0088cc; font-family: serif; } </style> <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- Le fav and touch icons --> <link rel="shortcut icon" href="__PUBLIC__/assets/ico/favicon.ico"> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="__PUBLIC__/assets/ico/apple-touch-icon-144-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="__PUBLIC__/assets/ico/apple-touch-icon-114-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="__PUBLIC__/assets/ico/apple-touch-icon-72-precomposed.png"> <link rel="apple-touch-icon-precomposed" href="__PUBLIC__/assets/ico/apple-touch-icon-57-precomposed.png"> </head> <!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]--> <!--[if IE 7 ]> <body class="ie ie7"> <![endif]--> <!--[if IE 8 ]> <body class="ie ie8"> <![endif]--> <!--[if IE 9 ]> <body class="ie ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--> <body> <!--<![endif]--> <div class="navbar"> <div class="navbar-inner"> <div class="container-fluid"> <ul class="nav pull-right"> </ul> <a class="brand" href=""><span class="first">CSV</span> <span class="second"> drawing tool</span></a> </div> </div> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="dialog span4"> <div class="block"> <div class="block-heading">忘記密碼<font>(輸入注冊時填寫的工號和郵箱)</font></div> <div class="block-body"> <form name="signin" id="form1" method="post" action="{:U('Login/wjpas')}"> <label>工號</label> <input type="text" class="span12" name="num" value="" id="num"> <label>郵箱</label> <input type="text" class="span12" name="email" value="" id="email"> <label>新密碼</label> <input type="password" class="span12" name="password" value="" id="psw"> <button type="submit" target-form="form1" class="am-btn am-btn-primary am-btn-block ajax-post" style="display:none;">提交</button> <button type="button" onclick="sub(this.form,this)" class="btn btn-primary pull-right" >提交</button> <div class="clearfix"></div> </form> </div> </div> </div> </div> <script type="text/javascript" src="__PUBLIC__/Js/login.js"></script> <script type="text/javascript"> function sub(o){ //表單驗證部分 if($("#num").val() == ""){ layer.alert('工號不能為空') ; $("#num").focus(); return false ; } if($("#email").val() == ""){ layer.alert('郵箱不能為空') ; $("#email").focus(); return false ; } if($("#psw").val() == ""){ layer.alert('新密碼不能為空') ; $("#psw").focus(); return false ; } $(".ajax-post").trigger('click') ; } </script> </body> </html>