<!--#include file="inc/conn.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="inc/function.asp"-->
<%
dim Action,UserName,FoundErr,ErrMsg
dim rsUser,sqlUser
Action=trim(request("Action"))
UserName=trim(request("UserName"))
if Action="" and session("UserName")="" then
	response.redirect "UserServer.asp"
end if
if Action="Modify" and UserName<>"" then
	Set rsUser=Server.CreateObject("Adodb.RecordSet")
	sqlUser="select * from [User] where UserName='" & UserName & "'"
	rsUser.Open sqlUser,conn,1,3
	if rsUser.bof and rsUser.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的用户！</li>"
	else
		dim OldPassword,Password,PwdConfirm
		OldPassword=trim(request("OldPassword"))
		Password=trim(request("Password"))
		PwdConfirm=trim(request("PwdConfirm"))
		if OldPassword="" then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>请输入旧密码！</li>"
		else
			if Instr(OldPassword,"=")>0 or Instr(OldPassword,"%")>0 or Instr(OldPassword,chr(32))>0 or Instr(OldPassword,"?")>0 or Instr(OldPassword,"&")>0 or Instr(OldPassword,";")>0 or Instr(OldPassword,",")>0 or Instr(OldPassword,"'")>0 or Instr(OldPassword,",")>0 or Instr(OldPassword,chr(34))>0 or Instr(OldPassword,chr(9))>0 or Instr(OldPassword,"")>0 or Instr(OldPassword,"$")>0 then
				errmsg=errmsg+"<br><li>旧密码中含有非法字符</li>"
				founderr=true
			else
				if md5(OldPassword)<>rsUser("Password") then
					FoundErr=True
					ErrMsg=ErrMsg & "<br><li>你输入的旧密码不对，没有权限修改！</li>"
				end if
			end if
		end if
		if strLength(Password)>12 or strLength(Password)<6 then
			founderr=true
			errmsg=errmsg & "<br><li>请输入新密码(不能大于12小于6)。</li>"
		else
			if Instr(Password,"=")>0 or Instr(Password,"%")>0 or Instr(Password,chr(32))>0 or Instr(Password,"?")>0 or Instr(Password,"&")>0 or Instr(Password,";")>0 or Instr(Password,",")>0 or Instr(Password,"'")>0 or Instr(Password,",")>0 or Instr(Password,chr(34))>0 or Instr(Password,chr(9))>0 or Instr(Password,"")>0 or Instr(Password,"$")>0 then
				errmsg=errmsg+"<br><li>新密码中含有非法字符</li>"
				founderr=true
			end if
		end if
		if PwdConfirm="" then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>请输入确认密码！</li>"
		else
			if PwdConfirm<>Password then
				FoundErr=True
				ErrMsg=ErrMsg & "<br><li>确认密码与新密码不一致！</li>"
			end if
		end if
		if FoundErr<>true then
			rsUser("Password")=md5(Password)
			rsUser.update
		end if
	end if
	rsUser.close
	set rsUser=nothing
	if FoundErr=True then
		call WriteErrMsg()
	else
	    response.write"<SCRIPT language=JavaScript>alert('成功修改密码！');"
        response.write"javascript:history.go(-1)</SCRIPT>"
	end if
else
%>
<!-- #include file="Head.asp" -->
<TABLE cellSpacing=0 cellPadding=0 width=1002 align=center border=0>
  <TBODY>
    <TR>
      <TD vAlign=top width=210><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
          <TBODY>
            <TR>
              <TD><IMG height=40 src="imgbly/lt29.gif" width=210></TD>
            </TR>
            <TR>
              <TD align=middle><TABLE 
            style="BORDER-RIGHT: #e9e9e9 1px solid; BORDER-TOP: #e9e9e9 1px solid; BORDER-LEFT: #e9e9e9 1px solid; BORDER-BOTTOM: #e9e9e9 1px solid" 
            cellSpacing=0 cellPadding=0 width=178 border=0>
                <TBODY>
                  <TR>
                    <TD height=15>&nbsp;</TD>
                  </TR>
                  <TR>
                    <TD><TABLE cellSpacing=0 cellPadding=0 width=162 align=center 
                  border=0>
                        <TBODY>
                          <TR>
                            <TD class=lNav><a href="UserEdit.asp">修改会员资料</a></TD>
                          </TR>
                          <TR>
                            <TD class=lNav1><a href="UserEditPwd.asp">修改会员密码</a></TD>
                          </TR>
                          <TR>
                            <TD class=lNav><a href="UserOrder.asp">购物订单查询</a></TD>
                          </TR>
                          <TR>
                            <TD class=lNav><a href="FeedbackMember.asp">站内留言中心</a></TD>
                          </TR>
                          <TR>
                            <TD class=lNav><a href="UserLogout.asp?Action=Ch">退出会员中心</a></TD>
                          </TR>
                        </TBODY>
                    </TABLE></TD>
                  </TR>
                  <TR>
                    <TD height=15>&nbsp;</TD>
                  </TR>
                </TBODY>
              </TABLE></TD>
            </TR>
          </TBODY>
      </TABLE></TD>
      <TD style="BACKGROUND: url(imgbly/bg_body.gif) repeat-y 50% top" vAlign=top><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
          <TBODY>
            <TR>
              <TD><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                  <TBODY>
                    <TR>
                      <TD background=imgbly/bg_rt.gif><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                          <TBODY>
                            <TR>
                              <TD><IMG src="imgbly/rt16.gif" width="209" height=41></TD>
                              <TD>&nbsp;</TD>
                              <TD class=loc 
                      style="BACKGROUND: url(img/bg_rtjiao.gif) no-repeat right 50%; COLOR: #9f9f9f" 
                      align=right>你现在的位置：<A href="index.asp">首页</A> &gt; 服务中心 &gt;修改密码</TD>
                            </TR>
                          </TBODY>
                      </TABLE></TD>
                      <TD width=17>&nbsp;</TD>
                    </TR>
                  </TBODY>
              </TABLE></TD>
            </TR>
          </TBODY>
        </TABLE>
          <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="3%" height="34" rowspan="3">&nbsp;</td>
              <td width="94%">&nbsp;</td>
              <td width="3%" rowspan="3">&nbsp;</td>
            </tr>
            <tr>
              <td><FORM name="Form1" action="UserEditPwd.asp" method="post">
                <table width=90% border=0 align="center" cellpadding=3 cellspacing=1 bgcolor="#E3E3E3">
                  <TR align=center bgcolor="#FFFFFF"  >
                    <TD height=40 colSpan=2><font color="#FFffff" class=font14><b>修改</b></font><font color="#FF6600" class=font14><b>修改用户密码</b></font></TD>
                  </TR>
                  <TR bgcolor="#FFFFFF">
                    <TD width="120" align="right">用 户 名：</TD>
                    <TD><%=session("UserName")%>
                        <input name="UserName" type="hidden" value="<%=session("UserName")%>"></TD>
                  </TR>
                  <TR bgcolor="#FFFFFF">
                    <TD width="120" align="right">旧 密 码：</TD>
                    <TD><INPUT   type=password maxLength=16 size=30 name=OldPassword>
                    </TD>
                  </TR>
                  <TR bgcolor="#FFFFFF">
                    <TD width="120" align="right">新 密 码：</TD>
                    <TD><INPUT   type=password maxLength=16 size=30 name=Password>
                    </TD>
                  </TR>
                  <TR bgcolor="#FFFFFF">
                    <TD width="120" align="right">确认密码：</TD>
                    <TD><INPUT name=PwdConfirm   type=password id="PwdConfirm" size=30 maxLength=16>
                    </TD>
                  </TR>
                  <TR align="center" bgcolor="#FFFFFF">
                    <TD height="40" colspan="2"><input name="Action" type="hidden" id="Action" value="Modify">
                        <input name=Submit   type=submit id="Submit" value=" 保 存 ">
                    </TD>
                  </TR>
                </TABLE>
              </form></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
            </tr>
        </table></TD>
    </TR>
  </TBODY>
</TABLE>

<!-- #include file="Inc/Foot.asp" -->
</BODY></HTML>
<%
end if
call CloseConn()
%>