<!--#include file="inc/conn.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="inc/function.asp"-->
<%
if CheckUserLogined()=False then
	response.Redirect "UserLogin.asp"
end if

dim Action,UserName,FoundErr,ErrMsg
dim rsUser,sqlUser
Action=trim(request("Action"))
if Action="Modify" then
	UserName=trim(request("UserName"))
else
	UserName=Trim(Request.Cookies("asp163")("UserName"))
end if
if  UserName="" then
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>参数不足！</li>"
end if
if FoundErr=true then
	call WriteErrMsg()
else
	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>"
		call writeErrMsg()
	else
		if Action="Modify" then
			dim Sex,Email,Homepage,QQ,MSN
			Sex=trim(Request("Sex"))
			Email=trim(request("Email"))
			Homepage=trim(request("Homepage"))
			QQ=trim(request("QQ"))
			MSN=trim(request("MSN"))
			if Sex="" then
				founderr=true
				errmsg=errmsg & "<br><li>性别不能为空</li>"
			else
				sex=cint(sex)
				if Sex<>0 and Sex<>1 then
					Sex=1
				end if
			end if
			if Email="" then
				founderr=true
				errmsg=errmsg & "<br><li>Email不能为空</li>"
			else
				if IsValidEmail(Email)=false then
					errmsg=errmsg & "<br><li>您的Email有错误</li>"
			   		founderr=true
				end if
			end if
			if QQ<>"" then
				if not isnumeric(QQ) or len(cstr(QQ))>10 then
					errmsg=errmsg & "<br><li>QQ号码只能是4-10位数字，您可以选择不输入。</li>"
					founderr=true
				end if
			end if
			if MSN<>"" then
				if IsValidEmail(MSN)=false then
					errmsg=errmsg & "<br><li>你的MSN有误。</li>"
					founderr=true
				end if
			end if
			if FoundErr<>true then
				rsUser("Sex")=Sex
				rsUser("Email")=Email
				rsUser("HomePage")=HomePage
				rsUser("QQ")=QQ
				rsUser("MSN")=MSN
				rsUser.update
				call WriteSuccessMsg("成功修改用户信息！")
			else
				call WriteErrMsg()
			end if
		else

%>
<html>
<head>
<title>修改注册用户信息</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css">
</head>
<body>
<br>
<FORM name="Form1" action="UserModifyInfo.asp" method="post">
  <table width=400 border=0 align="center" cellpadding=2 cellspacing=1 class='border'>
    <TR align=center class='title'> 
      <TD height=22 colSpan=2><font class=en><b>修改注册用户信息</b></font></TD>
    </TR>
    <TR class="tdbg" > 
      <TD width="120" align="right"><b>用 户 名：</b></TD>
      <TD> <%=Trim(Request.Cookies("asp163")("UserName"))%> <input name="UserName" type="hidden" value="<%=Trim(Request.Cookies("asp163")("UserName"))%>"></TD>
    </TR>
    <TR class="tdbg" > 
      <TD width="120" align="right"><strong>性别：</strong></TD>
      <TD> <INPUT type=radio value="1" name=sex <%if rsUser("Sex")=1 then response.write "CHECKED"%>>
        男 &nbsp;&nbsp; <INPUT type=radio value="0" name=sex <%if rsUser("Sex")=0 then response.write "CHECKED"%>>
        女</TD>
    </TR>
    <TR class="tdbg" > 
      <TD width="120" align="right"><strong>Email地址：</strong></TD>
      <TD> <INPUT name=Email value="<%=rsUser("Email")%>" size=30   maxLength=50> 
      </TD>
    </TR>
    <TR class="tdbg" > 
      <TD width="120" align="right"><strong>主页：</strong></TD>
      <TD> <INPUT   maxLength=100 size=30 name=homepage value="<%=rsUser("HomePage")%>"></TD>
    </TR>
    <TR class="tdbg" > 
      <TD width="120" align="right"><strong>QQ号码：</strong></TD>
      <TD> <INPUT name=QQ value="<%=rsUser("QQ")%>" size=30 maxLength=20></TD>
    </TR>
    <TR class="tdbg" > 
      <TD width="120" align="right"><strong>MSN：</strong></TD>
      <TD> <INPUT name=msn value="<%=rsUser("MSN")%>" size=30 maxLength=50></TD>
    </TR>
    <TR align="center" class="tdbg" > 
      <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>
</body>
</html>
<%
		end if
	end if
	rsUser.close
	set rsUser=nothing
end if
call CloseConn()
%>
