• ajax修改密码


    <div>用户名:<input type="text" id="uid" /><span id="tt" style="display:none">用户名不存在</span></div>
    
    <div>密&nbsp;码:<input type='password' id='pwd' /><span id="ts" style="display:none">密码不正确</span></div>
    <div>新密码:<input type="password" id="pod" /><span id="ta" style="display:none">新密码不能为空</span></div>
    <div>新密码:<input type="password" id="ppd" /><span id="tb" style="display:none">第二次新密码不能为空</span></div>
    <div ><input type="button" value="修改" id="btn" />&nbsp;<a href="dengluzhu.php"><input type="submit" value="返回" /></a></div>
    
    
    
    
    
    
    
    
    </div>
    </div>
    
    
    
    <script type="text/javascript">
    $(document).ready(function(e){
    $("#uid").blur(function(){
        var uid = $("#uid").val()
        $.ajax({
            url:"uidchuli.php",
            data:{uid:uid},
            dataType:"TEXT",
            type:"POST",
            success: function(data){
                //alert(data);
                if(data.trim()==0)
        {
            
            $("#tt").css("display","block");
            return false;
        }
        else if(data.trim()==1)
        {
            $("#tt").css("display","none");
            
        }
        }
        })
        })
        })
    $("#pwd").blur(function(){
        var uid = $("#uid").val();
        var  pwd = $("#pwd").val();
        $.ajax({
            url:"uidpwdchuli.php",
            data:{pwd:pwd,uid:uid},
            type:"POST",
            dataType:"TEXT",
            success: function(data){
        
                if(data.trim()=="no")
        {
            $("#ts").css("display","block");
            return false;
        }
                if(data.trim()=="ok")
        {
            $("#ts").css("display","none");
            
            
        }
        }
        })
        })
    $("#pod").blur(function(){
        var pod = $("#pod").val();
        if(pod.trim().length==0)
        {
            
        $("#ta").css("display","block");    
        return false;
        }
        else
        {
            
        $("#ta").css("display","none")    
        }
        })
        $("#ppd").blur(function(){
            var ppd = $("#ppd").val();
            if(ppd.trim().length==0)
        {
            
        $("#tb").css("display","block");    
        return false;
        }
        else
        {
            
        $("#tb").css("display","none")    
        }
        })
    
    
    $("#btn").click(function(){
        var uid = $("#uid").val();
        var pod = $("#pod").val();
        var ppd = $("#ppd").val();
        
        if(pod.trim().length!=ppd.trim().length)
        {
        alert("输入的两次密码不相同");    
        return false;
        }
        
        else
        {
        $.ajax({
            url:"xugaichuli.php",
            data:{uid:uid,pod:pod,ppd:ppd},
            dataType:"TEXT",
            type:"POST",
            success: function(data){
            if(data.trim().length==1)
            {
                alert("修改成功");
                
            }
            }
            })
        }
        
        });
    </script>
    
    
    
    //ajax修改主页
    
    
    
    
    
    <?php
    
    $uid=$_POST["uid"];
    
    include("js/DBDA.class.php");
    
    $db=new DBDA();
    $sql="select count(*) from admin where adminname='{$uid}'";
    
    echo $db->StrQuery($sql);
    
    
    
    ?>
    
    
    //uid处理页面
    
    
    
    
    <?php
    
    $uid=$_POST["uid"];
    $pwd=$_POST["pwd"];
    include("js/DBDA.class.php");
    
    $db=new DBDA();
    $sql="select password from admin where adminname='{$uid}'";
    
     $mm=$db->StrQuery($sql);
    if($mm==$pwd && $pwd!="")
    {
        
        echo "ok";    
        
    }
    else
    {
    echo "no";    
        
    }
    
    
    //判断密码处理页面
    
    
    
    
    
    <?php
    
    $uid=$_POST["uid"];
    $pod=$_POST["pod"];
    include("js/DBDA.class.php");
    $db=new DBDA();
    
    
    $sql="update admin set password='{$pod}' where adminname='{$uid}'";
    
    echo $db->StrQuery($sql,0);
    
    
    ?>
    
    
    
    //执行修改处理页面
  • 相关阅读:
    区块链学习笔记
    Ubuntu下Maven配置与Maven项目创建教程
    Java数字签名——ECDSA算法
    Java数字签名——DSA算法
    Java数字签名——RSA算法
    Python——Web.py詳解
    Flask從入門到入土(五)——Flask与数据库
    Flask從入門到入土(四)——登錄實現
    Flask從入門到入土(三)——Web表單
    Flask從入門到入土(三)——模板
  • 原文地址:https://www.cnblogs.com/liuran123/p/6112933.html
Copyright © 2020-2023  润新知