?? memberedit.asp
字號:
<%@LANGUAGE="VBScript" CODEPAGE="936"%>
<!--#include file="SESSION.asp" -->
<!--#include file="CONN.asp" -->
<!--#include file="MD5.asp" -->
<!--#include file="CHAR.asp" -->
<%
response.Buffer=true
response.Expires=0
username=session("username")
dim errmsg,founderr
errmsg=""
founderr=false
'修改密碼
sub editsys
passwd=replace(trim(request.Form("oldpasswd")),"'","")
if passwd="" then
errmsg=errmsg+"<br>"+"<li>密碼不能為空!"
founderr=true
exit sub
end if
passwd=md5(passwd)
set rs1=server.CreateObject("adodb.recordset")
strsql="select username,passwd from [user] where username='"&username&"' and passwd='"&passwd&"'"
rs1.open strsql,conn,1,3
if rs1.bof or rs1.eof then
errmsg=errmsg+"<br>"+"<li>您輸入的密碼不正確!"
founderr=true
exit sub
end if
newpasswd=replace(trim(request.Form("newpasswd")),"'","")
renewpasswd=replace(trim(request.Form("renewpasswd")),"'","")
if newpasswd="" or len(passwd)<6 then
errmsg=errmsg+"<br>"+"<li>請輸入您的新密碼!"
founderr=true
exit sub
end if
if renewpasswd="" or len(passwd)<6 then
errmsg=errmsg+"<br>"+"<li>請確認您的新密碼!"
founderr=true
exit sub
end if
if newpasswd<>renewpasswd then
errmsg=errmsg+"<br>"+"<li>前后輸入的密碼不一致!"
founderr=true
exit sub
end if
newpasswd=md5(newpasswd)
if founderr=false then
rs1("passwd")=newpasswd
rs1.update
errmsg="<li>修改密碼成功!"
end if
rs1.close
set rs1=nothing
end sub
'修改個人資料
sub editbasic
answer=trim(request("answer"))
if answer="" then
errmsg=errmsg+"<br>"+"<li>請輸入您的問題。"
founderr=true
end if
question=trim(request("question"))
question2=trim(request("question2"))
if question="" then
errmsg=errmsg+"<br>"+"<li>請輸入您的問題答案。"
founderr=true
else
'如果question和question2的值一樣,則不做更新
if question<>question2 then
question=md5(question)
end if
end if
realname=trim(request("realname"))
if realname="" or len(realname)>5 then
errmsg=errmsg+"<br>"+"<li>請填寫您的姓名(長度不能大于5位)。"
founderr=true
end if
sex=trim(request("sex"))
if sex="male" then
sex="男"
else
sex="女"
end if
birthday=trim(Request.Form("birthyear"))&"年"&trim(Request.Form("birthmonth"))&"月"&trim(Request.Form("birthday"))&"日"
if isdate(birthday) then
birthday=cdate(birthday)
else
birthday=""
end if
if trim(request("mphone"))<>"" then
if not isnumeric(trim(request("mphone"))) or len(trim(request("mphone")))<>11 then
errmsg=errmsg+"<br>"+"<li>您的手機號碼有錯誤。"
founderr=true
else
mphone=trim(request("mphone"))
end if
end if
homeaddr=trim(request("homeaddr"))
if trim(request("homephone"))<>"" then
homephone=trim(request("homephone"))
end if
if trim(request("postcode"))<>"" then
if not isnumeric(trim(request("postcode"))) or len(trim(request("postcode")))>8 then
errmsg=errmsg+"<br>"+"<li>您的家庭郵政編碼有錯誤。"
founderr=true
else
postcode=trim(request("postcode"))
end if
end if
jobaddr=trim(request("jobaddr"))
if trim(request("jobphone"))<>"" then
jobphone=trim(request("jobphone"))
end if
if IsValidEmail(trim(request("email")))=false then
errmsg=errmsg+"<br>"+"<li>您的Email有錯誤。"
founderr=true
else
email=trim(request("email"))
end if
if trim(request("oicq"))<>"" then
if not isnumeric(trim(request("oicq"))) or len(trim(request("oicq")))>12 then
errmsg=errmsg+"<br>"+"<li>Oicq號碼只能是4-12位數字,您可以選擇不輸入。"
founderr=true
else
oicq=trim(request("oicq"))
end if
end if
if trim(request("msn"))<>"" then
if IsValidEmail(trim(request("msn")))=false then
errmsg=errmsg+"<br>"+"<li>您的MSN有錯誤。"
founderr=true
else
msn=trim(request("msn"))
end if
end if
homepage=trim(request("homepage"))
if left(homepage,7)<>"http://" and homepage<>"" then
homepage="http://"&homepage
end if
if not founderr then
set rs2=server.CreateObject("adodb.recordset")
strsql="select * from [user] where username='"&username&"'"
rs2.open strsql,conn,2,3
rs2("answer")=answer
rs2("question")=question
rs2("realname")=realname
rs2("sex")=sex
if birthday<>"" then
rs2("birthday")=birthday
end if
rs2("mphone")=mphone
rs2("homeaddr")=homeaddr
rs2("homephone")=homephone
rs2("postcode")=postcode
rs2("jobaddr")=jobaddr
rs2("jobphone")=jobphone
rs2("email")=email
rs2("oicq")=oicq
rs2("msn")=msn
rs2("homepage")=homepage
rs2.update
rs2.close
set rs2=nothing
errmsg="<li>個人資料已經更新!"
end if
end sub
if request.Form("method")="sys" then
call editsys
end if
if request.Form("method")="basic" then
call editbasic
end if
set rs=server.CreateObject("adodb.recordset")
strsql="select * from [user] where username='"&username&"'"
rs.open strsql,conn,1,1
dim sex,birthyear,birthmonth,birthday
sex=rs("sex")
birthyear=year(rs("birthday"))
birthmonth=month(rs("birthday"))
birthday=day(rs("birthday"))
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-cn">
<title><%=classname%>同學錄--個人資料修改</title>
<link href="css/class.css" type=text/css rel=stylesheet>
<script language="JavaScript">
<!--
function checkform1()
{if (form1.oldpasswd.value.length==0) {
alert("請輸入您原來帳號的密碼!");
form1.oldpasswd.focus();
return false;
}
if (form1.newpasswd.value.length==0) {
alert("請輸入您的新密碼!");
form1.newpasswd.focus();
return false;
}
if (form1.renewpasswd.value.length==0) {
alert("請確認您的新密碼!");
form1.renewpasswd.focus();
return false;
}
if (form1.newpasswd.value != form1.renewpasswd.value) {
alert("您兩次輸入的密碼不一致!請重新輸入!");
form1.newpasswd.focus();
return false;
}
return true
}
function checkform2(){
if (document.form2.realname.value.length==0){
alert("請輸入您的真實姓名!")
document.form2.realname.focus();
return false;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -