<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                # 引入 # **[PHPMailer](https://github.com/PHPMailer/PHPMailer)** 郵件 github地址:https://github.com/PHPMailer/PHPMailer 第一步下載:https://github.com//PHPMailer/PHPMailer/archive/master.zip、 第二步把下載文件放到 extend 文件夾下面,建立一個文件夾叫做PHPMailer,全部放在里面 第三步 在自己方法里面引入兩個文件 ~~~ require_once("../extend/static/PHPMailer/src/PHPMailer.php"); require_once("../extend/static/PHPMailer/src/SMTP.php"); ~~~ # Html 代碼頁面 ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="Pragma" content="no-cache"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/> <meta name="format-detection" content="telephone=yes"/> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <title>手機注冊信息</title> <!-- Bootstrap core CSS--> <!-- 最新版本的 Bootstrap 核心 CSS 文件 --> <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script> <script src="https://cdn.bootcss.com/sweetalert/2.1.2/sweetalert.min.js"></script> <style type="text/css"> body{ margin: 0; padding: 0; } .modal_content{ padding: 30px; display: flex; justify-content: center; flex-direction: column; } .modal_content>div{ margin-bottom: 20px; } .modal_content>h5:first-child{ margin:30px 0px; } #dialog label{ color: #666; } #phone1{ display: block; width: 100%; height: 70px; background: none; padding-top: 30px; border: 0; outline:none; text-align: center; margin-top: -30px; font-size: 16px; border-bottom: 1px solid rgba(0,0,0,.2); border-radius: 0; } .code1{ display: flex; flex-direction: row; justify-content: space-between; width: 100%; height: 70px; background: none; padding-top: 30px; margin-top: -30px; font-size: 16px; border-bottom: 1px solid rgba(0,0,0,.2); border-radius: 0; } #code1{ width: calc(100% - 90px); height: 55px; background: none; padding-top: 20px; border: 0; outline:none; text-align: center; margin-top: -20px; font-size: 16px; } #btnSendCode1{ width: 90px; height: 30px; padding: 0 5px; margin: 0; font-size: 14px; text-align: center; background: transparent; border-radius: 30px; color: #a07941; border-color: #a07941; } ::-webkit-input-placeholder { /* WebKit browsers */ font-size: 14px; color: rgba(0,0,0,.4); } :-moz-placeholder { /* Mozilla Firefox 4 to 18 */ font-size: 14px; color: rgba(0,0,0,.4); } ::-moz-placeholder { /* Mozilla Firefox 19+ */ font-size: 14px; color: rgba(0,0,0,.4); } :-ms-input-placeholder { /* Internet Explorer 10+ */ font-size: 14px; color: rgba(0,0,0,.4); } .next{ text-align: center; margin: 20px 0; } .next button{ width: 100%; height: 45px; padding: 0; margin: 0; background: #007BFF; color: #fff; border: 0; outline:none; border-radius: 3px; } </style> </head> <body> <div class="container"> <div class="row"> <div class="col-md-3"></div> <div class="modal_content col-md-6"> <form action="post" id="register"> <div> <label for="phone1">手機號:</label><br /> <input id="phone1" type="text" autocomplete="off" name="phone" value="461476246@qq.com" placeholder="請輸入已綁定的手機號"/> </div> <div> <label for="phone1">密碼:</label><br /> <input type="password" autocomplete="off" name="password" style=" display: block; width: 100%; height: 70px; background: none; padding-top: 30px; border: 0; outline: none; text-align: center; margin-top: -30px; font-size: 16px; border-bottom: 1px solid rgba(0,0,0,.2); border-radius: 0;"/> </div> <div> <label for="code1">驗證碼:</label> <div class="code1"> <input id="code1" type="text" name="codes" autocomplete="off" placeholder="短信驗證碼"/> <button id="btnSendCode1" type="button" class="btn btn-default" value="" >獲取驗證碼</button> </div> </div> <div class="next"> <button onClick="binding()" type="button">確定</button> </div> </form> </div> <div class="col-md-3"></div> </div> </div> <script language="javascript"> // var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;//手機號正則 let phoneReg = /(^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$)/; //郵箱驗證 $(function () { //點擊發送驗證碼 $('body').on('click', '#btnSendCode1', function () { let phone = $.trim($('#phone1').val()); if (!phoneReg.test(phone)) { alert(" 請輸入有效的手機號碼"); return false; } $('body').off('click', '#btnSendCode1'); //向后臺發送處理數據 $.ajax({ type: 'post', //提交后臺php文件 url: "{:url('index/index/email')}", // 得到表單提交的數據 data:{'phone':phone} , dataType: 'json', //回調處理 success: function(data){ if (data.status ==1) { swal({ //彈出后臺返回的消息 text: data.message, icon: "success", button: false }); }else{ swal({ text: data.message, icon: "warning", button: false }); } } }) LockButton('#btnSendCode1', 60); }) //讀取cookie if ($.cookie("djsendtime") != undefined && !isNaN($.cookie("djsendtime"))) { //讀取到了cookie值 let djsendtime = $.cookie("djsendtime"); let now = new Date().getTime(); //當前時間戳 let locksecends = parseInt((djsendtime - now) / 1000); if (locksecends <= 0) { $.cookie("djsendtime", null); } else { LockButton('#btnSendCode1', locksecends); } } }) // 按鈕倒計時 var LockButton = function (btnObjId, locksecends) { //1.獲取當前系統時間 //2.獲取 locksecends 后的系統時間 //3.用cookie保存到期時間 //4.每次加載后獲取cookie中保存的時間 //5.用到期時間減去當前時間獲取倒計時 let djsendtime = $.cookie("djsendtime"); if (djsendtime == null || djsendtime == undefined || djsendtime == 'undefined' || djsendtime == 'null') { var now = new Date().getTime(); //當前時間戳 var endtime = locksecends * 1000 + now; //結束時間戳 $.cookie("djsendtime", endtime); //將結束時間保存到cookie } $(btnObjId).addClass('disabled').attr('disabled', 'disabled').text( + locksecends + '秒后獲取'); $('body').off('click', '#btnSendCode1SMS'); let timer = setInterval(function () { locksecends--; $(btnObjId).text(locksecends + '秒后獲取'); if (locksecends <= 0) { //倒計時結束清除cookie值 $.cookie("djsendtime", null); $(btnObjId).removeClass('disabled').removeAttr('disabled').text('重新獲取'); clearInterval(timer); } }, 1000); }; /*提交*/ function binding(){ //向后臺發送處理數據 $.ajax({ type: 'post', //提交后臺php文件 url: "{:url('index/index/res')}", // 得到表單提交的數據 data:$('#register').serialize() , dataType: 'json', //回調處理 success: function(data){ if (data.status ==1) { swal({ //彈出后臺返回的消息 text: data.message, icon: "success", button: false }); }else{ swal({ text: data.message, icon: "warning", button: false }); } } }) } </script> </body> </html> ~~~ ![](https://box.kancloud.cn/38be8c92652e2c2480663e5d1da5a451_1386x630.png) # php 處理代碼 ~~~ //發送郵件 public function email(){ $email = \think\facade\Request::post('phone'); require_once("../public/static/PHPMailer/src/PHPMailer.php"); require_once("../public/static/PHPMailer/src/SMTP.php"); // 實例化PHPMailer核心類 $mail = new \PHPMailer\PHPMailer(); // 是否啟用smtp的debug進行調試 開發環境建議開啟 生產環境注釋掉即可 默認關閉debug調試模式 $mail->SMTPDebug = 1; // 使用smtp鑒權方式發送郵件 $mail->isSMTP(); // smtp需要鑒權 這個必須是true $mail->SMTPAuth = true; // 鏈接qq域名郵箱的服務器地址 $mail->Host = 'smtp.qq.com'; // 設置使用ssl加密方式登錄鑒權 $mail->SMTPSecure = 'ssl'; // 設置ssl連接smtp服務器的遠程服務器端口號 $mail->Port = 465; // 設置發送的郵件的編碼 $mail->CharSet = 'UTF-8'; // 設置發件人昵稱 顯示在收件人郵件的發件人郵箱地址前的發件人姓名 $mail->FromName = 'Mrs gao'; // smtp登錄的賬號 QQ郵箱即可 $mail->Username = '461476246@qq.com'; // smtp登錄的密碼 使用生成的授權碼 $mail->Password = 'rjipjeasbxaybgec'; // 設置發件人郵箱地址 同登錄賬號 $mail->From = '461476246@qq.com'; // 郵件正文是否為html編碼 注意此處是一個方法 $mail->isHTML(true); // 設置收件人郵箱地址 $mail->addAddress($email); // 添加該郵件的主題 $mail->Subject = '郵件主題'; // 添加郵件正文 $mail->Body = '<h1>Hello World'.$this->codes().' </h1>'; $mail->SMTPOptions = array( 'ssl' => array( 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true ) ); //郵件發送,必須寫 $mail -> send() ; // 發送郵件 返回狀態 return ['status'=>'1','message'=>'郵件發送成功']; } //定義一個六位驗證碼 public function codes($len =6){ $str = ''; for($i=0;$i<$len;$i++){ $str .= mt_rand(0,9); } session('codes',$str); session('time',time()+60); return $str; } //接受數據驗證處理 public function res(Request $request){ $data =$request->param(); if ($data['codes'] !=\session('codes')){ return ['status'=>'1','message'=>'兩次驗證碼不一致']; } if (time() >=\session('time')){ return ['status'=>'1','message'=>'驗證碼已經過期']; } //后面就是插入數據庫處理 $ifno = Db::table('users')->data([ 'phone'=>$data['phone'], 'password'=>sha1($data['password']) ])->insert(); if ($ifno){ return ['status'=>'1','message'=>'注冊成功']; } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看