123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- $requestMethod = strtolower($_SERVER['REQUEST_METHOD']);
- if($requestMethod=="post"){
- header("Content-type: text/json; charset=utf-8");
- $phone=$_POST['phone']??"";
- $pass=$_POST['pass']??"";
- $statement=$pdo->prepare("select * from users where phone=? and password=?");
- $statement->execute([$phone,$pass]);
- $res=$statement->fetch(PDO::FETCH_ASSOC);
- if(!$res){
- exit(json_encode(['code'=>0,"msg"=>"账号或密码错误"]));
- }
- $_SESSION['admin_id']=$res['id'];
- echo json_encode(['code'=>1,"msg"=>"登陆成功"]);
- exit();
- }
- ?>
- <!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" oninput="value=value.replace(/[^\d]/g,'')">
- <input type="password" id="password" placeholder="请输入密码" lay-verify="required">
- <input type="button" value="登录" id="regBtn">
- <a href="/register">还没有账号?点击注册</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/js/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();
- if (!isPoneAvailable(phone)) {
- layer.alert("请输入正确的手机号");
- return false;
- }
- var password = $("#password").val();
- if (phone == '') {
- layer.alert("手机号不能为空");
- return false;
- }
- if (password == '') {
- layer.alert("密码不能为空");
- return false;
- }
- $.post("/login", { phone: phone ,pass:password}, 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>
|