123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- $method_type=strtolower($_SERVER["REQUEST_METHOD"]);
- if($method_type=="post"){
- header("Content-type: text/json; charset=utf-8");
- $phone=$_POST['phone'];
- $password=$_POST['pass'];
- $time=date("Y-m-d H:i:s");
- $user_stmit=$pdo->query("select * from users where `phone`='".$phone."'".' limit 1');
- $user=$user_stmit->fetch(PDO::FETCH_ASSOC);
- if(!empty($user))exit(json_encode(['code'=>0,"msg"=>"改手机号已存在"]));
- $stmit=$pdo->prepare("insert into users(`phone`,`password`,`created_at`, `updated_at`)values(?,?,?,?)");
- $stmit->execute(array($phone,$password,$time,$time));
- $id=$pdo->lastInsertId();
- $_SESSION['admin_id']=$id;
- exit(json_encode(array("code"=>1,"msg"=>"注册成功")));
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0, user-scalable=no">
- <title>话费充值平台</title>
- <meta name="keywords" content="话费充值平台">
- <meta name="description" content="话费充值平台">
- <meta name="author" content="mosheng QQ:304366">
- <link rel="stylesheet" href="static/css/frozenui.css">
- <link rel="stylesheet" href="static/css/login.css">
- <link rel="stylesheet" href="static/css/base.css">
- <link rel="stylesheet" href="/static/layer/layer.css?v=3.1.1" id="layuicss-layer">
- </head>
- <body>
- <div class="c-title">
- <div class="logo">
- <img src="static/picture/icon_1.png" width="42" height="32" alt="">
- </div>
- <p class="name">话费充值平台</p>
- </div>
- <div class="c-login">
- <h1>注册</h1>
- <div class="loginForm">
- <input type="text" id="phone" placeholder="请输入手机号码" lay-verify="phone">
- <!-- <img src="static/picture/captcha.html" id="capt" class="codeBtn" onclick="this.src = this.src +Math.random()" style="width: 100%;height: 35px;" class="layadmin-user-login-codeimg">-->
- <input type="password" id="password" placeholder="请输入密码" lay-verify="required">
- <input type="password" id="password_1" placeholder="请输入确认密码" lay-verify="required">
- <input type="button" value="注册" id="regBtn">
- <a href="/login">已有账号?点击登录</a>
- </div>
- </div>
- <div class="layui-trans layadmin-user-login-footer">
- <p>Copyright © 版权所有 浙江榕木信息科技有限公司 <br> <a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer nofollow"><i class="iconimg iconimg-beian"></i><span>浙ICP备2023051306号-1</span></a></p>
- </div>
- <script type="text/javascript" src="static/js/jquery.min.js"></script>
- <script type="text/javascript" src="static/js/base.js"></script>
- <script src="/static/layer/layer.js"></script>
- <script type="text/javascript">
- function isPoneAvailable(poneInput) {
- var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
- if (!myreg.test(poneInput)) {
- return false;
- } else {
- return true;
- }
- }
-
- $('#regBtn').click(function() {
- var phone = $("#phone").val();
- var code = $("#code").val();
- var pass = $("#password").val();
- var pass1 = $("#password_1").val();
- if (phone == '') {
- layer.alert("请输入手机号");
- return false;
- }
- if (!isPoneAvailable(phone)) {
- layer.alert("请输入正确的手机号");
- return false;
- }
- if (code == '') {
- layer.alert("短信验证码不能为空");
- return false;
- }
- if (pass == '') {
- layer.alert("密码不能为空");
- return false;
- }
- if (pass1 == '') {
- layer.alert("确认密码不能为空");
- return false;
- }
- if (pass != pass1) {
- layer.alert("两次密码不一致");
- return false;
- }
- $.post("/register", { phone: phone ,code:code,pass,pass}, function(data) {
- if (data.code == 0) {
- layer.msg(data.msg);
- } else {
- if (data.code == 1) {
- layer.msg(data.msg, {time:2000,shift: 6 }, function () {
- window.location.href = "/home";
- });
- }
- }
- return false;
- });
- });
- </script>
- </body>
- </html>
|