php+ajax实现登录验证
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('账号或密码错误!');}
}
});
}
Copyright © 2015 - 2016 系统登陆
check.php
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';
}
}
当前名称:php+ajax实现登录验证
URL标题:http://jxruijie.cn/article/ijgegh.html
