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('账号或密码错误!');}
}
});
}
账 号:
autocomplete="off">
密 码:
class="password form-control x319 in">
验证码:
看不清,换一张
记住登陆账号!
class="btn btn-primary btn-lg"> 登 录 
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 '
';
//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';
}
}