您好,登錄后才能下訂單哦!
login.js
$(document).ready(function(){ //提交表單 $('#submit_btn').click(function(){ show_loading(); //var myReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; //郵件正則 if($('#account').val() == ''){ show_err_msg('賬號還沒填呢!'); $('#account').focus(); //}//else if(!myReg.test($('#email').val())){ //show_err_msg('您的郵箱格式錯咯!'); //$('#email').focus(); }else if($('#password').val() == ''){ show_err_msg('密碼還沒填呢!'); $('#password').focus(); }else{ //show_msg('登錄成功咯! 正在為您跳轉...','shop.php'); postdata(); //button被點擊時執行postdata函數 } }); }); function postdata() { $.ajax({ type: "post", url: "check.php", data:"&checkcode="+$("#j_captcha").val()+"&account="+$("#account").val()+"&pass="+$("#password").val(), error: function(){ alert('Error loading php document'); }, success: function(data){ if (data == "success") {show_msg('登錄成功咯! 正在為您跳轉...','shop.php'); } else if(data == "codefalse"){ show_err_msg('驗證碼輸入錯誤!'); $('#j_captcha').focus(); }else {show_err_msg('賬號或密碼錯誤!');} } }); } <script type="text/javascript" src="js/login.js"></script><!---正則表達判斷登錄信息格式----> </head> <body> <div class="page-container"> <div class="main_box"> <div class="login_box"> <div class="login_logo"> <img src="p_w_picpaths/logo.png" > </div> <div class="login_form"> <div class="form-group"> <label for="j_username" class="t">賬 號:</label> <input id="account" name="account" type="text" class="form-control x319 in" autocomplete="off"> </div> <div class="form-group"> <label for="j_password" class="t">密 碼:</label> <input id="password" name="pass" type="password" class="password form-control x319 in"> </div> <div class="form-group"> <label for="j_captcha" class="t">驗證碼:</label> <input id="j_captcha" name="checkcode" type="text" class="form-control x164 in" onblur="if(this.value==''){this.value='驗證碼:'}" onclick="if(this.value=='驗證碼:'){this.value='';}"> <img src="../inc/cc.php" height="40"> <a id="kanbuq" href="javascript:void(0);" onClick="$(this).prev().attr('src','../inc/cc.php?'+new Date())">看不清,換一張</a> </div> <div class="form-group"> <label class="t"></label> <label for="j_remember" class="m"> <input id="j_remember" type="checkbox" value="true"> 記住登陸賬號!</label> <label id="div2"></label> </div> <div class="form-group space"> <label class="t"></label> <button type="submit" id="submit_btn" class="btn btn-primary btn-lg"> 登 錄  </button> <input type="reset" value=" 重 置 " class="btn btn-default btn-lg"> </div> </div> </div> <div class="bottom">Copyright © 2015 - 2016 系統登陸</div> </div> </div>
check.php
<?php include '../inc/db.php'; session_start(); $pc = strtolower(trim($_POST['checkcode'])); $sc = strtolower($_SESSION['code']); if($pc=='' || $pc!=$sc){ //header('location:login.html'); echo 'codefalse'; }else{ $a = $_POST['account']; $p = $_POST['pass']; $pass = m($p,$a); //$cuspass=query('customer','cuspassword',"cusaccount=$a"); $stmt = $db->prepare('select cuspassword,id from customer where cusaccount=? '); $stmt->execute([$a]); $rs = $stmt->fetchAll(3); //echo '<pre>'; //print_r( $rs); //echo $rs[0][0]; //exit; if($pass==$rs[0][0]){ $_SESSION['customer']=[$a,$rs[0][1]]; unset($_SESSION['code']); //header('location:shop.php'); echo 'success'; }else{ //header('location:login.html'); echo 'false'; } }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。