<div>用户名:<input type="text" id="uid" /><span id="tt" style="display:none">用户名不存在</span></div> <div>密 码:<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" /> <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); ?> //执行修改处理页面