<%@ page contentType="text/html; charset=gb2312" %>
<jsp:useBean id="db" scope="page" class="chatweb.conn" />
<html>
<head>
<title>
modify
</title>
<link href="../chat.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<script language="JavaScript" type="text/JavaScript">
function check(){
	if(document.all.newPassword.value!=document.all.renewpassword.value){
				window.alert("两次输入的密码不一致");
			}
    	else {
	     document.all.form1.submit();
	  }
	}
</script>
<body bgcolor="#FFF7DD">
<div align="center">
  <%
if(request.getMethod().toUpperCase().equals("POST")){
	String oldPassword=request.getParameter("oldpassword");
	String newPassword=request.getParameter("newPassword");
	String user=session.getAttribute("username").toString();
	if(db.modify(user,oldPassword,newPassword)){%>
  <script language="JavaScript" type="text/JavaScript">
		window.alert("密码修改成功");
		</script>
  <%}
	else{%>
  <script language="JavaScript" type="text/JavaScript">
		window.alert("密码修改失败");
		</script>
  <%}
}
%>
  <br>
  <form name="form1" method="post" action="">
    <table width="80%" border="0" cellspacing="1" class="mytable">
      <tr bgcolor="#FFF7DD"> 
        <td nowrap> 
          <div align="right">旧密码：</div></td>
        <td width="90%"> 
          <input name="oldpassword" type="password" id="oldpassword">
        </td>
      </tr>
      <tr bgcolor="#FFF7DD"> 
        <td nowrap> 
          <div align="right">新密码：</div></td>
        <td> 
          <input name="newPassword" type="password" id="newPassword"></td>
      </tr>
      <tr bgcolor="#FFF7DD"> 
        <td nowrap> 
          <div align="right">重复新密码：</div></td>
        <td> 
          <input name="renewpassword" type="password" id="renewpassword" value=""></td>
      </tr>
      <tr bgcolor="#FFF7DD"> 
        <td colspan="2" nowrap> 
          <div align="center">
            <input type="button" name="Submit" value="提交" onClick="check()">
            <input type="button" name="Submit2" value="取消" onClick="window.close()">
          </div></td>
      </tr>
    </table>
  </form>
</div>
</body>
</html>
