<?php
  if(isset($_POST['oldPwd'])&&isset($_POST['newPwd'])&&isset($_POST['repPwd'])&&$_POST['oldPwd']!=null&&$_POST['newPwd']!=null&&$_POST['repPwd']!=null){
    $newPwd=$_POST['newPwd'];
    $oldPwd=$_POST['oldPwd'];
    $repPwd=$_POST['repPwd']; 	
  	if($newPwd!=$repPwd){
     		echo  "<script>alert('两次密码输入不同');history.back();</script>";
     	}else {
     		$sql="select * from user where user=$user and password=$oldPwd";
     		if(mysql_query($sql)){
     			$sql1="update user set password=$newPwd where user=$user";
     			if(mysql_query($sql1)){
     				echo "<script>alert('修改密码成功，下次登陆生效！');history.back();</script>";
     			}else{
     				echo "<script>alert('更新数据库失败，请重试！');history.back();</script>";
     			}
     		}else{
     			echo "<script>alert('你输入的原密码有错误，无法修改！');history.back();</script>";
     		}
     	}
  }else{
  	echo "<script>alert('输入数据不完整，无法处理！');history.back();</script>";
    }
  ?>