<!--#include file="conn.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
else
if request.cookies("sundxshop")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');location.href='index.asp' ;</script>"
response.End
end if
end if
%>
<title>修改密码</title>
<%if FormatSQL(SafeRequest("action",0))="save" then%>
<!--#include file="../func.asp"-->
<%if session("rank")=3 then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('你无权更改密码！');history.go(-1);</script>"
response.End
end if
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from admin where admin='"&session("admin")&"'",conn,1,3
if md5(trim(request.form("UserPassword")))<>rs("UserPassword") then
response.Write "<script language=javascript>alert('原密码错误，请返回重新输入');history.go(-1);</script>"
response.End
else
rs("UserPassword")=md5(trim(request.form("UserPassword2")))
rs.Update
rs.Close
set rs=nothing
session("admin")=""
session("rank")=""
response.Write "<script language=javascript>alert('修改成功，请用新密码重新登录！');history.go(-1);</script>"
end if
response.End
end if
%>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" BGCOLOR="#39867B">
  <tr> 
    <td height="20" BGCOLOR="#39867B" align="center"><font color="#ffffff">更改管理密码</font></td>
  </tr>
  <tr> 
    <td height="163" bgcolor="#FFFFFF"> 
	<table width="200" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
        <form name="renUserPassword" method="post" action="change.asp?action=save">
          <tr bgcolor="#FFFFFF"> 
            <td width="100">用户名：</td>
            <td width="150" align="center"><font color=red><%=session("admin")%></font></td>
          </tr>
          <tr bgcolor="#FFFFFF"> 
            <td>原密码：</div></td>
            <td align="center"><input name="UserPassword" type="Password" id="UserPassword" size="12"></td>
          </tr>
          <tr bgcolor="#FFFFFF"> 
            <td>新密码：</div></td>
            <td align="center"><input name="UserPassword1" type="Password" id="UserPassword1" size="12"></td>
          </tr>
          <tr bgcolor="#FFFFFF"> 
            <td>确认密码：</td>
            <td align="center"><input  name="UserPassword2" type="Password" id="UserPassword2" size="12"></td>
          </tr>
          <tr bgcolor="#FFFFFF"> 
            <td colspan="2" align="center"><input onClick="return check();" type="submit" name="Submit" value="确定更改"></td>
          </tr>
        </form>
      </table></td>
  </tr>
</table>
<br>
<!--#include file="footer.asp"-->
<script LANGUAGE="javascript">
<!--
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
function check()
{
  if(checkspace(document.renUserPassword.UserPassword.value)) {
	document.renUserPassword.UserPassword.focus();
    alert("原密码不能为空！");
	return false;
  }
  if(checkspace(document.renUserPassword.UserPassword1.value)) {
	document.renUserPassword.UserPassword1.focus();
    alert("新密码不能为空！");
	return false;
  }
    if(checkspace(document.renUserPassword.UserPassword2.value)) {
	document.renUserPassword.UserPassword2.focus();
    alert("确认密码不能为空！");
	return false;
  }
    if(document.renUserPassword.UserPassword1.value != document.renUserPassword.UserPassword2.value) {
	document.renUserPassword.UserPassword1.focus();
	document.renUserPassword.UserPassword1.value = '';
	document.renUserPassword.UserPassword2.value = '';
    alert("新密码和确认密码不相同，请重新输入");
	return false;
  }
	document.admininfo.submit();
  }
//-->
</script> 

