<!--#include file="conn.asp"-->
<!-- #include file="inc/const.asp" -->
<!-- #include file="chkuser.asp" -->
<!--#include file="inc/char.asp"-->
<!--#include file="inc/theme.asp"-->
<!--#include file="md5.asp"-->
<!--#include file="inc/chkinput.asp"-->
<%
stats="修改资料"
dim psw
dim password
dim oldpassword
dim quesion
dim answer
dim usercookies
if membername="" then
  	errmsg=errmsg+"<br>"+"<li>您没有<a href=login.asp target=_blank>登录</a>。"
	founderr=true
else
	if request("action")="updat" then
				
		if request("psw")="" then
		  	errmsg=errmsg+"<br>"+"<li>请输入您的密码。"
			founderr=true
		elseif trim(request("psw"))=trim(memberword) then
			password=request("psw")
		else
			password=md5(request("psw"))
		end if
		if request("quesion")="" then
		  	errmsg=errmsg+"<br>"+"<li>请输入密码提示问题。"
			founderr=true
		else
		quesion=request("quesion")
		end if
		if request("answer")="" then
		  	errmsg=errmsg+"<br>"+"<li>请输入密码提示问题答案。"
			founderr=true
		elseif request("answer")=request("oldanswer") then
			answer=request("answer")
		else
		answer=md5(request("answer"))
		end if
	else
		call nav()
		call headline(1)
		call userinfo()
	end if
end if

if founderr then
	call nav()
	call headline(1)
	call error()
else
	if request("action")="updat" then
		if founderr then
			call nav()
			call headline(1)
			call error()
		else
			call update()
			call nav()
			call headline(1)
			if founderr then
			call error()
			else
			call success()
			end if
		end if
	end if
end if
call endline()

sub userinfo()
	set rs=server.createobject("adodb.recordset")
	sql="Select * from [User] where username='"&trim(membername)&"'"
	rs.open sql,conn,1,1
	if rs.eof and rs.bof then
		errmsg=errmsg+"<br>"+"<li>该用户名不存在。"
		founderr=true
	else
%>
<table border=0 cellpadding=6 cellspacing=1 width="<%=TableWidth%>" height=29 align=center bgcolor="<%=TableBackColor%>"><tr class=coolbg bgColor="<%=aTablebodyColor%>" align=center>
<td width=14% ><B><a href=usermanager.asp ><FONT COLOR=#000000>控制面板首页</font></a></B></td>
<td width=14% ><a href=mymodify.asp?name=<%=membername%> ><B><FONT COLOR=#000000>基本资料修改</font></B></a></td>
<td width=14% bgColor="<%=TablebodyColor%>"><a href=modifypsw.asp?name=<%=membername%>> <B><FONT COLOR=#000000> 用户密码修改</font></B></a></td>
<td width=14% > <a href=modifyadd.asp?name=<%=membername%>> <B><FONT COLOR=#000000>修改联系资料</font></B></a></td>
<td width=14% ><a href=favlist.asp><B><FONT COLOR=#000000>用户收藏管理</font></B></a></td>
<td width=14% ><a href=usersms1.asp><B><FONT COLOR=#000000>用户短信服务</font></B></a></td>
<td width=14% ><a href=friendlist1.asp><B><FONT COLOR=#000000>编辑好友列表</font></B></a></B>
</td></tr></table><br>
<form action="modifypsw.asp?action=updat&username=<%=htmlencode(membername)%>" method=POST name="theForm">
<table cellpadding=0 cellspacing=0 border=0 width=<%=tablewidth%> bgcolor=<%=Tablebackcolor%> align=center>
        <tr>
            <td>
                <table cellpadding=3 cellspacing=1 border=0 width=100%>
      </tr>   
      <tr bgcolor=<%=Tablebodycolor%>>    
        <td width="40%"><font color="<%=TableContentColor%>"><B>密码</B>：<BR>如要修改请直接输入</font></td>   
        <td width="60%">    
          <input type="password" name="psw"   value="<%=htmlencode(RS("userpassword"))%>" size=30 maxlength=13>   
        </td>   
      </tr>   
      <tr bgcolor=<%=Tablebodycolor%>>    
        <td width="40%"><font color="<%=TableContentColor%>"><B>密码问题</B>：<BR>请填写做为密码答案依据</font></td>   
        <td width="60%">    
          <input type=text name="quesion" size=30   value="<%=htmlencode(rs("quesion"))%>">
        </td>   
      </tr>  
      <tr bgcolor=<%=Tablebodycolor%>>    
        <td width="40%"><font color="<%=TableContentColor%>"><B>问题答案</B>：<BR>请认真填写以便您日后取回密码<BR>答案采用了MD5加密，只供取回密码使用，如要修改可直接填写。</font></td>   
        <td width="60%">    
          <input type=text name="answer" size=30 value="<%=htmlencode(rs("answer"))%>">
          <input type=hidden name="oldanswer"   value="<%=htmlencode(rs("answer"))%>">
        </td>   
      </tr>  
    <tr class=coolbg align="center"> 
      <td colspan="2" width="100%" bgcolor=<%=Tabletitlecolor%>>
            <input type=Submit   value="更 新" name="Submit"> &nbsp; <input type="reset" name="Submit2"   value="清 除">
      </td>
    </tr>  
    </table>   </td></tr></table> 
</form>   
</body>
</html> 
<%
	end if
	rs.close
	set rs=nothing
end sub

sub update()
	set rs=server.createobject("adodb.recordset")
	sql="Select * from [User] where userid="&userid
	rs.open sql,conn,1,3
	if rs.eof and rs.bof then
		errmsg=errmsg+"<br>"+"<li>该用户名不存在。"
		founderr=true
	else
		rs("userpassword")=password
		
		rs("quesion")=quesion
		rs("answer")=answer

		rs.Update
        rs.close
		set rs=nothing		
		Response.Cookies("aspsky")("password") = password
		Response.Cookies("aspsky").path=cookiepath	
	end if
end sub

sub success()
%>
<table cellpadding=0 cellspacing=0 border=0 width="<%=tablewidth%>" bgcolor=<%=Tablebackcolor%> align=center>
        <tr>
            <td>
                <table cellpadding=3 cellspacing=1 border=0 width=100%>
    <tr class=coolbg align="center"> 
      <td width="100%" bgcolor=<%=Tabletitlecolor%>><font color="<%=TablefontColor%>">成功：修改资料</font></td>
    </tr>
    <tr> 
      <td width="100%" bgcolor=<%=Tablebodycolor%>><font color="<%=TableContentColor%>"><b>恭喜您，您的资料修改成功</b></font><br>
      </td>
    </tr>
    <tr align="center"> 
      <td width="100%" bgcolor=<%=Tabletitlecolor%>>
<a href="javascript:history.go(-1)"> << 返回上一页</a>
      </td>
    </tr>  
    </table>   </td></tr></table>
<%
end sub
	set rs=nothing 
	stats="修改个人资料"
%>   
<!--#include file=footer.asp-->

