📄 register.asp
字号:
<!-- #include file="const.asp" -->
<!-- #include file="convertpw.asp"-->
<html>
<head>
<title><%=sitename%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/css.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="10" align="center" valign="top">
<!-- #include file="topbar.asp" -->
</td>
</tr>
<tr>
<td align="center" valign="top"> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="12" bgcolor="#ECE9D9"> </td>
<td width="1" bgcolor="#E8BC3C"></td>
<td width="10"> </td>
<td align="center" valign="top">
<%
dim reg1
reg1=trim(request.Form("reg"))
if reg1="done" then
call opendb()
call addreg()
call closedb()
else
call reg()
end if
%>
</td>
<td width="10"> </td>
<td width="1" bgcolor="#E8BC3C"></td>
<td width="12" bgcolor="#ECE9D9" valign="top"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="10" align="center" valign="bottom"> <!-- #include file="bottombar.asp" --> </td>
</tr>
</table>
<%sub reg()%>
<form action="register.asp" method="post" name="regform" id="regform" onSubmit="javascript:chkField();return false;">
<table width="500" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td> <p><strong>继续注册前请先阅读 本BBS 协议</strong><br>
<br>
<textarea name="textarea" cols="80" rows="12" class="input1">欢迎您加入本BBS参加交流和讨论,本BBS为公共论坛,为维护网上公共秩序和社会稳定,请您自觉遵守以下条款:
一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播下列信息:
(一)煽动抗拒、破坏宪法和法律、行政法规实施的;
(二)煽动颠覆国家政权,推翻社会主义制度的;
(三)煽动分裂国家、破坏国家统一的;
(四)煽动民族仇恨、民族歧视,破坏民族团结的;
(五)捏造或者歪曲事实,散布谣言,扰乱社会秩序的;
(六)宣扬封建迷信、淫秽、色情、赌博、暴力、凶杀、恐怖、教唆犯罪的;
(七)公然侮辱他人或者捏造事实诽谤他人的,或者进行其他恶意攻击的;
(八)损害国家机关信誉的;
(九)其他违反宪法和法律行政法规的;
(十)进行商业广告行为的。
二、互相尊重,对自己的言论和行为负责。</textarea>
</p>
<p><span class="v8">我同意上述协议</span>
<input type="checkbox" name="agree" value="Y" >
</p></td>
</tr>
</table>
<br>
<br>
<table width="500" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#E8BC3C">
<tr>
<td colspan="2" class="v8b" align="center" background="images/bg4.gif">注册表单</td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="8" colspan="2" bgcolor="#FFFFFF" class="v8b"></td>
</tr>
<tr>
<td colspan="2" bgcolor="#FFFFFF"><span class="v8">说明:</span> <br>
以下每一项都必需填写,否则注册失败.<br>
<br> </td>
</tr>
<tr>
<td width="131" align="right" bgcolor="#FFFFFF" class="v7b"> 帐号</td>
<td nowrap bgcolor="#FFFFFF"> <input name="uname" id="uname" type="text" class="input1" value="" size="17" maxlength="12">
* (2到20个字符)</td>
</tr>
<tr>
<td align="right" bgcolor="#FFFFFF" class="v7b">密码</td>
<td nowrap bgcolor="#FFFFFF"> <input name="password" type="password" class="input1" size="17" maxlength="12">
* (3到16个字符)</td>
</tr>
<tr>
<td align="right" bgcolor="#FFFFFF" class="v7b">重输密码</td>
<td bgcolor="#FFFFFF"> <input name="repassword" class="input1" type="password" size="17" maxlength="12">
* </td>
</tr>
<tr>
<td align="right" bgcolor="#FFFFFF" class="v7b">Email</td>
<td bgcolor="#FFFFFF"> <input name="email" class="input1" type="text" value="" size="40" maxlength="80">
* </td>
</tr>
<tr>
<td align="right" bgcolor="#FFFFFF" class="v7b">性别</td>
<td bgcolor="#FFFFFF"><input name="sex" type="radio" value="0" checked>
男
<input type="radio" name="sex" value="1">
女</td>
</tr>
<tr>
<td align="right" bgcolor="#FFFFFF" class="v7b">提示问题</td>
<td bgcolor="#FFFFFF"><input name="question" class="input1" type="text" id="question" value="" size="30" maxlength="80">
* (6到30个字符)</td>
</tr>
<tr>
<td align="right" bgcolor="#FFFFFF" class="v7b">答案</td>
<td bgcolor="#FFFFFF"><input name="answer" class="input1" type="text" id="answer" value="" size="30" maxlength="80">
* (6到30个字符)</td>
</tr>
<tr>
<td align="right" bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF">注意:<br>
"提示问题"和"答案"必项认真填写,并尽量复杂化!<br>
依据它们将能找回您丢失的注册帐号;同样,可能会给他人利用,以盗取您的帐号密码,因此请您保证它们的安全性。<br>
"提示问题"和"答案"在注册成功后,不提供更改。<br>
</td>
</tr>
<tr>
<td align="right" bgcolor="#FFFFFF"> </td>
<td height="40" bgcolor="#FFFFFF"> <input name="reg" type="hidden" value="done">
<input name="Submit" type="submit" class="input1" value="提交">
<input name="cancel" type="button" class="input1" id="cancel" value="放弃" onClick="history.go(-1)">
</td>
</tr>
</table>
<SCRIPT language=JavaScript>
function chkField()
{
if (document.regform.agree.checked) {
if (document.regform.uname.value.length <2)
{
alert ('无效的帐号名(不能少于2个字符)');
document.regform.uname.focus();
return false;
}
if (document.regform.password.value.length <3)
{
alert ('无效的密码!(不能少于3个字符)');
document.regform.password.focus();
return false;
}
if (document.regform.password.value != document.regform.repassword.value)
{
alert ('两次输入的密码不一样!');
document.regform.password.focus();
return false;
}
if (document.regform.email.value.length<8)
{
alert ('请输入有效的email地址!');
document.regform.email.focus();
return false;
}
if (document.regform.question.value.length <6)
{
alert ('无效的提示问题(不能少于6个字符)');
document.regform.question.focus();
return false;
}
if (document.regform.answer.value.length <6)
{
alert ('无效的提示问题答案(不能少于6个字符)');
document.regform.answer.focus();
return false;
}
document.regform.submit();
} else {
alert ('在未同意注册协议条约(点击"同意" 复选框)前,不能注册!');
document.regform.agree.focus();
}
}
</script>
</form>
<%end sub%>
<%sub addreg()%>
<TABLE WIDTH=421 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0 bgcolor="#FFFFFF">
<TR valign="top" bgcolor="#FFFFFF">
<TD>
<%
dim name,rs,sql,er,question,answer,i
dim pw,pw2,sex,email,regtime
er="no"
name=trim1(request.Form("uname"))
dim errmsg(5)
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from m3_users where name ='"&name&"'"
rs.open sql,conn,1,1
if not rs.eof then
errmsg(1)="the login name had been used, please re input ."
er="yes"
else
regtime=now()
pw=request.Form("password")
pw2=request.Form("repassword")
sex=request.Form("sex")
email=trim(request.Form("email"))
question=trim(request.Form("question"))
answer=trim(request.Form("answer"))
if len(name)>20 then errmsg(1)="无效的帐号名字,不能超过20个字符"
if len(name)<2 then errmsg(1)="无效的帐号名字,不能少于2个字符"
if name="游客" then errmsg(1)="帐号名字不能为'游客'"
if name="guest" then errmsg(1)="帐号名字不能为'guest'"
if name="test" then errmsg(1)="帐号名字不能为'test'"
if name="m3" then errmsg(1)="帐号名字不能为'm3'"
if not IsValidName(name) then errmsg(1)="帐号中包含有非法字符!"
if len(pw)<3 then errmsg(2)="无效的密码,不能少于3个字符"
if pw="" then errmsg(2)="请填写密码"
if len(pw)>16 then errmsg(2)="无效的密码,不能超过16个字符"
if pw<>pw2 then errmsg(2)="两次输入的密码不一样!"
if len(question)>30 then errmsg(3)="无效的提示问题,不能超过30个字符"
if len(question)<5 then errmsg(3)="无效的提示问题,不能少于6个字符"
if len(answer)>30 then errmsg(3)="无效的提示问题答案,不能超过30个字符"
if len(answer)<5 then errmsg(3)="无效的提示问题答案,不能少于6个字符"
if email<>"" then
if not isvalidemail(email) then errmsg(4)=email&" 不是有效的Email地址"
end if
end if
rs.close
for i=1 to 4
if trim(errmsg(i))<>"" then er="yes"
next
%>
<%if er="yes" then%>
<table border="0" width="420" bordercolor="#336699" cellspacing="0" align="center">
<tr>
<td width="100%"> <table width="100%" border="0" cellspacing="0">
<tr>
<td width="100%" height="24" align="center" background="images/bg4.gif">
<b><font color="#FF0000">注册失败!</font></b></td>
</tr>
<tr>
<td background="images/bg4.gif"> 可能的出错原因:</td>
</tr>
<%for i=1 to 4%>
<%if errmsg(i)<>"" then %>
<tr>
<td width="100%"> <ul>
<li> <font color="red"> <%=errmsg(i)%> </font> </li>
</ul></td>
</tr>
<%end if%>
<%next%>
<tr>
<td width="100%" align="center" height="30"> [ <a href="" onclick="history.go(-1);return false;">返回</a>
] </td>
</tr>
</table></td>
</tr>
</table>
<%response.end%>
<%else
pw=convertpw(pw)
rs.open "m3_users",conn,3,2
rs.addnew
rs("name") =name
rs("password") =pw
rs("sex") =sex
rs("email") =email
rs("question") =question
rs("answer") =answer
rs("regtime") =regtime
rs("power") =1
rs("messkey") =1
rs("pub") =1
rs("credit")=0
rs("meili")=0
rs("weiwang")=0
rs("jingyan")=0
rs("money")=1000
rs("post")=0
rs("logintimes")=0
rs("level1")=0
rs("ip") =request.ServerVariables("LOCAL_ADDR")
rs.update
rs.close
set rs=nothing
response.Cookies("matrix3")("matrix3_name") =name
response.Cookies("matrix3")("matrix3_pw") =pw
response.Cookies("matrix3")("matrix3_admin") =""
response.Cookies("matrix3")("usercookies") =""
response.Cookies("matrix3").path ="/bbs/"
response.write"<script>alert(""注册成功 !"");location.href='index.asp';</script>"
response.End()
end if
%>
</TD>
</TR>
</TABLE>
<%end sub%>
</body>
</html>
<%
function IsValidName(str)
dim i,c
IsValidName = false
if isnull(str) or str="" then exit function
if instr(str,"""")>0 then exit function
for i = 1 to Len(str)
c = Lcase(Mid(str, i, 1))
if InStr("<> &'@`*%#.", c)>0 then exit function
next
IsValidName=true
end function
function IsValidEmail(email)
dim names, name, i, c
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, "..") > 0 then
IsValidEmail = false
end if
end function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -