• js和cookie登陆验证


    这是在截取的登陆功能代码

            count = document.cookie.split(';')[0];//以分号为分隔符对cookie进行分割alert(document.cookie.split(';')[0]);取出--count=3
            if(count.split('=')[1] >= 3){//alert(document.cookie.split('=')[1]);取出--3;PHPSESSID
                alert('因为您的非法操作,您将无法再执行登录操作');
                return false;
            }
            $('regimg').style.visibility = "visible";
            url = 'login_chk.php?act='+(Math.random())+'&name='+$('lgname').value+'&pwd='+$('lgpwd').value;
           xmlhttp = new XMLHttpRequest();
            xmlhttp.open('get',url,true);
            xmlhttp.onreadystatechange = function(){
                if(xmlhttp.readyState == 4&& xmlhttp.status == 200){
                        msg = xmlhttp.responseText;
                //msg即是login_chk.php里面的reback???
                        if(msg == '0'){
                            alert('您还没有激活,请先登录邮箱进行激活操作。');
                        }else if(msg == '1'){
                            alert('用户名或密码输入错误,您还有2次机会');
                            $('lgpwd').select();
                        }else if(msg == '2'){
                            alert('用户名或密码输入错误,您还有1次机会');
                            $('lgpwd').select();
                        }else if(msg == '3'){
                            alert('因为登录次数过多,您的帐号已被冻结,请联系管理员');
                            $('lgname').select();
                        }else if(msg == '4'){
                            alert('用户名输入错误');
                            $('lgname').select();
                        }else if(msg == '-1'){
                            alert('登录成功');
                            location = 'main.php';
                        }else{
                            alert(msg);
                        }
                        $('regimg').style.visibility = "hidden";
                    }
                }
            xmlhttp.send(null);
        }
    

    这是处理数据的代码

            count = document.cookie.split(';')[0];//以分号为分隔符对cookie进行分割alert(document.cookie.split(';')[0]);取出--count=3
            if(count.split('=')[1] >= 3){//alert(document.cookie.split('=')[1]);取出--3;PHPSESSID
                alert('因为您的非法操作,您将无法再执行登录操作');
                return false;
            }
            $('regimg').style.visibility = "visible";
            url = 'login_chk.php?act='+(Math.random())+'&name='+$('lgname').value+'&pwd='+$('lgpwd').value;
           xmlhttp = new XMLHttpRequest();
            xmlhttp.open('get',url,true);
            xmlhttp.onreadystatechange = function(){
                if(xmlhttp.readyState == 4&& xmlhttp.status == 200){
                        msg = xmlhttp.responseText;
                //msg即是login_chk.php里面的reback???
                        if(msg == '0'){
                            alert('您还没有激活,请先登录邮箱进行激活操作。');
                        }else if(msg == '1'){
                            alert('用户名或密码输入错误,您还有2次机会');
                            $('lgpwd').select();
                        }else if(msg == '2'){
                            alert('用户名或密码输入错误,您还有1次机会');
                            $('lgpwd').select();
                        }else if(msg == '3'){
                            alert('因为登录次数过多,您的帐号已被冻结,请联系管理员');
                            $('lgname').select();
                        }else if(msg == '4'){
                            alert('用户名输入错误');
                            $('lgname').select();
                        }else if(msg == '-1'){
                            alert('登录成功');
                            location = 'main.php';
                        }else{
                            alert(msg);
                        }
                        $('regimg').style.visibility = "hidden";
                    }
                }
            xmlhttp.send(null);
        }
    


     

  • 相关阅读:
    51 nod 1279 扔盘子
    洛谷 P2911 [USACO08OCT]牛骨头Bovine Bones
    1759 加减表达式
    1750 加法表达式
    poj 1006 Biorhythms
    vijos 1198 最佳课题选择
    poj 1390 Blocks
    codevs 3324 新斯诺克
    codevs 2075 yh女朋友的危机
    对拍器
  • 原文地址:https://www.cnblogs.com/aten/p/8684187.html
Copyright © 2020-2023  润新知