📄 reg.asp
字号:
<!--#include file="db_conn.asp"-->
<!--#include file="comm/comm.asp"-->
<!--#include file="comm/sub.asp"-->
<!--#include file="comm/my_request.asp"-->
<!--#include file="comm/md5.asp"-->
<!--begin TOP-->
<%
'说明 head(a,b,c)
'a为页标题
'b为页描述
'c为页关键字
call head(r(26)&"-会员注册",r(27),r(28))
action=my_request("action",0)
if action="save" then
call save()
end if
%><!--end TOP-->
<SCRIPT language="javascript">
<!--
function regsubmit()
{
if (document.reg.username.value == "")
{
window.alert("用户名不能为空!");
document.reg.username.focus();
return (false);}
var filter=/^\s*[.A-Za-z0-9_-]{5,15}\s*$/;
if (!filter.test(document.reg.username.value)) {
window.alert("用户名填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9 _ - .)长度不小于5个字符,不超过15个字符,注意不要使用空格。");
document.reg.username.focus();
document.reg.username.select();
return (false);
}
if (document.reg.password.value == "")
{
window.alert("密码不能为空!");
document.reg.password.focus();
return (false);}
var filter=/^\s*[.A-Za-z0-9_-]{5,15}\s*$/;
if (!filter.test(document.reg.password.value)) {
window.alert("密码填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9 _ - .)长度不小于5个字符,不超过15个字符,注意不要使用空格。");
document.reg.password.focus();
document.reg.password.select();
return (false);
}
if (document.reg.password2.value=="")
{window.alert('请填写确认密码!');
document.reg.password2.focus();
return false;}
if(document.reg.password2.value!==document.reg.password.value)
{
window.alert("两次密码输入不一致。")
return false;}
if (document.reg.email.value=="")
{window.alert('请输入电子邮件地址');
document.reg.email.focus();
return false;}
if (!IsEmail(document.reg.email.value))
{window.alert('您的电子邮箱地址填写有误!');
document.reg.email.focus();
return false;}
if (document.reg.question.value=="")
{window.alert('请填写问题!');
document.reg.question.focus();
return false;}
if (document.reg.question.value.length>50)
{window.alert('您的问题太长,只允许50字以内');
document.reg.question.focus();
return false;}
if (document.reg.answer.value=="")
{window.alert('请填写答案!');
document.reg.answer.focus();
return false;}
if (document.reg.answer.value.length>50)
{window.alert('您的答案太长,只允许50字以内');
document.reg.answer.focus();
return false;}
}
function IsEmail(argValue)
{var emailStr=argValue.toLowerCase();
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var emailPat=/^(.+)@(.+)$/;
var matchArray=emailStr.match(emailPat);
if (matchArray==null)
{return false;}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++)
{if (user.charCodeAt(i)>127)
{return false;}
}
for (i=0; i<domain.length; i++)
{if (domain.charCodeAt(i)>127)
{return false;}
}
if (user.match(userPat)==null)
{return false;}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null)
{for (var i=1;i<=4;i++)
{if (IPArray[i]>255)
{return false;}
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++)
{if (domArr[i].search(atomPat)==-1)
{return false;}
}
if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
{return false;}
if (len<2)
{return false;}
return true;
}
//--></SCRIPT>
<div align="center">
<table border="0" width="760" class="li_table" cellspacing="0">
<form action="reg.asp" method=post name=reg onsubmit="return regsubmit();">
<tr>
<td class="maincolor" height="26" align=center width="758" colspan="2">会 员 注 册</td>
</tr>
<tr>
<td width="281" align="right" height="25" valign="middle">用户名:</td>
<td width="475" height="25">
<input type="text" name="username" size="25" maxlength="20"><br>
<font color="#000080">* 用户名填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9 _ -
.)长度不小于5个字符,不超过15个字符,注意不要使用空格。</font></td>
</tr>
<tr>
<td width="281" align="right" height="25">密码:</td>
<td width="475" height="25">
<input type="password" name="password" size="28" maxlength="20"><font color="#000080">
* 同上</font></td>
</tr>
<tr>
<td width="281" align="right" height="25">确认密码:</td>
<td width="475" height="25">
<input type="password" name="password2" size="28" maxlength="20"><font color="#000080">
* 同上</font></td>
</tr>
<tr>
<td width="281" align="right" height="25" valign="middle">电子邮件地址:</td>
<td width="475" height="25">
<input type="text" name="email" size="25" maxlength="50"><br>
<font color="#000080">* 请正确填写,我们将给您邮件通知,此为重要的联系方式。</font></td>
</tr>
<tr>
<td width="281" align="right" height="25">找回密码的问题:</td>
<td width="475" height="25">
<input type="text" name="question" size="25" maxlength="30"><font color="#000080">
* 50字以内</font></td>
</tr>
<tr>
<td width="281" align="right" height="25">找回密码的答案:</td>
<td width="475" height="25">
<input type="text" name="answer" size="25" maxlength="30">
<input type="hidden" name="action" value="save">
<font color="#000080">
* 50字以内</font></td>
</tr>
<tr>
<td width="758" colspan="2" align=center>
<input type="submit" value="马上注册" name="B1"></td>
</tr>
</form>
</table>
</div>
<!--begin end-->
<%call boot()%><!--end end-->
<%
sub save()
username=my_request("username",0)
password=my_request("password",0)
password2=my_request("password2",0)
question=my_request("question",0)
answer=my_request("answer",0)
email=my_request("email",0)
if username="" or password="" or password2="" or (password<>password2) or question="" or answer="" or email="" then
Response.write "<script>alert(""对不起,您的注册信息有错误,请重新填写。"");location.href=""reg.asp"";</script>"
Response.end
else
password=md5(password,32)
answer=md5(answer,32)
sql="select txt_login_name,txt_login_pass,txt_question,txt_answer,txt_email,dat_regtime,id from user_info_list where txt_login_name='"&username&"'"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
if not rs.eof then
Response.write "<script language=JavaScript>{window.alert('对不起,此用户名已被占用。');window.history.go(-1)}</script>"
Response.end
else
rs.addnew
rs(0)=username
rs(1)=password
rs(2)=question
rs(3)=answer
rs(4)=email
rs(5)=now()
rs.update
session("chk_id")=rs(6)
session("chk_name")=username
session("chk_flag")=true
session("log_nums")=1
session("level")=0
rs.close
set rs=nothing
response.redirect "regok.asp"
end if
end if
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -