<?php
if(!isset($_SESSION['username'])){
   exit; 
}
$xiugai_sql="select * from user where username='{$username}'";
$xiugai_rst=mysql_query($xiugai_sql);
$xiugai_row=@mysql_fetch_assoc($xiugai_rst);
    


?>
<div style='width:1050px;height:755px;background:#fff;'>
<br/>
<br/>
<p style="font-size: 20px;text-align: center;color:#676767;">用户密码修改</p>
<br/>
<br/>
<table cellspacing="10" style="color:#676767;margin:0 auto;">
<form id="pass_xiugai_form" method="post" action="../page/pass_xiugai_add.php">
<input type="hidden" name="hidden_username" value="<?php echo $username; ?>">
<tr>
<td>原始密码:</td>
<td><input id="old_pass" class="auth" style="padding:5px 0px 5px 0px;width: 300px;" type="text" name="old_pass"></td>
<td style="width: 150px;"><span class="old_pass_error"></span></td>
</tr>
<tr>
<td>新的密码:</td>
<td><input id="new_pass" class="auth" style="padding:5px 0px 5px 0px;width: 300px;" type="text" name="new_pass"></td>
<td style="width: 150px;"><span class="new_pass_error"></span></td>
</tr>
<tr>
<td>重复密码:</td>
<td><input id="new_pass2" class="auth" style="padding:5px 0px 5px 0px;width: 300px;" type="text" name="new_pass2"></td>
<td style="width: 150px;"><span class="new_pass_error2"></span></td>
</tr>
<tr>
<td style="width: 100px;"></td>
<td><input id="btn" style="padding:5px 10px 5px 10px;" type="button" value="保存"></td>
</tr>
</form>
</table>
</div>
<?php 
@mysql_free_result($xiugai_rst);
mysql_close($con); 
?>
<script>
$("#old_pass").blur(function(){
var passval=$(this).val();
var thiz=$(this);
    $.post("../page/pass_ajax.php",{"old_username":"<?php echo $username; ?>","old_pass":passval},function(data){
        if(data=="no"){
            $(".old_pass_error").html("&nbsp;密码错误");
            $(".old_pass_error").css({"color":"red"});
            $(thiz).data({"e":0});
        }else{
            $(".old_pass_error").html("密码正确");
            $(".old_pass_error").css({"color":"green"});
            $(thiz).data({"e":1});
        }
    })
})


$("#new_pass").blur(function(){
new_pass_val=$(this).val();
    if(new_pass_val.length<6){
        $(".new_pass_error").html("密码长度小于6位");
        $(".new_pass_error").css({"color":"red"});
        $(this).data({"e":0});
    }else{
        $(".new_pass_error").html("");
        $(this).data({"e":1});
    }
})

$("#new_pass2").blur(function(){
var new_pass_val2=$(this).val();
    if(new_pass_val2!=new_pass_val){
        $(".new_pass_error2").html("两次密码不一致");
        $(".new_pass_error2").css({"color":"red"});
        $(this).data({"e":0});
    }else{
        $(".new_pass_error2").html("");
        $(this).data({"e":1});
    }
})

$("#btn").click(function(){
    $("#old_pass").blur();
    $("#new_pass").blur();
    $("#new_pass2").blur();
  tot=0;
  $(".auth").each(function(){
    tot+=$(this).data('e');
    
  })
  if(tot==3){$("#pass_xiugai_form").submit();}

})




</script>