所有程式碼展示
1,專案目錄展示
#2,所有程式碼展示:
register.php:
<?php ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="jquery-1.11.0.js" type="text/javascript"></script> <script type="text/javascript"> var countdown=60; function settime(obj){ //60秒倒計時 if (countdown == 0){ obj.removeAttribute("disabled"); obj.value="發(fā)送短信驗證碼"; countdown = 60; return; }else{ obj.setAttribute("disabled", true); obj.value="重新發(fā)送(" + countdown + ")"; countdown--; } setTimeout(function() { settime(obj) } ,1000) } $(document).ready(function() { $("#yzmfs").click(function () { //確保手機(jī)號不為空 var mobile=$("#phone").val(); if(mobile.length==0) { alert('請輸入手機(jī)號碼!'); $("#phone").focus(); return false; } if(mobile.length!=11) { alert('請輸入11位手機(jī)號!'); $("#phone").focus(); return false; } var myreg = /^((1[3|4|5|8][0-9]{1})+\d{8})$/; if(!myreg.test(mobile)) { alert('請輸入正確的手機(jī)號碼!'); document.getElementById("phone").focus(); return false; } //點擊發(fā)送短信驗證碼 $.ajax({ async : false, type: "get", url: "code.php", // data: {}, success: function (data) { //發(fā)送短信驗證碼 $.ajax({ async : false, type: "post", url: "smsyzm.php", // data: {"yzm": data, 'yzmtel': $('#phone').val()}, dataType: "json", success: function (data) { } }); } }); }) }) </script> </head> <body> <form action="check.php" method="post"> 用戶名:<input type="text" id="name" name="name"/><br> 密碼:<input type="password" id="pwd" name="pwd" /><br> 手機(jī)號:<input type="text" id="phone" name="phone" /><br> <input id="msg" hidden> <input type="text" id="yzm" name="yzm"><input type="button" id="yzmfs" value="發(fā)送短信驗證碼" onclick="settime(this)" /> <br> <input type="submit" id='register' name='register' value="注冊"> </form> </body> </html>
code.php:
#<?php $code_len=4; $code=array_merge(range('A','Z'),range('a','z'),range(1,9));//需要用到的數(shù)字或字母 $keyCode=array_rand($code,$code_len);//真正的驗證碼對應(yīng)的$code的鍵值 if($code_len==1){ $keyCode=array($keyCode); } shuffle($keyCode);//打亂數(shù)組 $verifyCode=""; foreach ($keyCode as $key){ $verifyCode.=$code[$key];//真正驗證碼 } echo base64_encode($verifyCode);
check.php:
<?php header("Content-type:text/html;charset=utf-8"); //判斷name和pwd不能為空 $name=isset($_POST['name'])?$_POST['name']:''; $pwd=isset($_POST['pwd'])?$_POST['pwd']:''; $phone=isset($_POST['phone'])?$_POST['phone']:''; //真正驗證碼 $code=isset($_POST['code'])?strtolower(base64_decode($_POST['code'])):''; //用戶輸入的驗證碼 $yzm=isset($_POST['yzm'])?strtolower($_POST['yzm']):''; if($name==null){ echo "姓名不能為空,3秒后跳回原注冊頁面"; header("Refresh:3;url=register.php"); die(); } if($pwd==null){ echo "密碼不能為空,3秒后跳回原注冊頁面"; header("Refresh:3;url=register.php"); die(); } if($yzm==""){ echo "未輸入驗證碼,3秒后跳回原注冊頁面"; header("Refresh:3;url=register.php"); die(); } if($phone==""){ echo "未輸入手機(jī)號,3秒后跳回原注冊頁面"; header("Refresh:3;url=register.php"); die(); } if($code==$yzm){ echo "注冊成功"; }else{ echo "驗證碼輸入錯誤,3秒后跳回原注冊頁面"; header("Refresh:3;url=register.php"); die(); }
################################################ ################剩餘的都是下載的SDK內(nèi)部的程式碼,看前面的專案實作過程改四個屬性即可######