无法验证用户名
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn/my_conn.asp"-->
<!--#include file="str_filter.asp"-->
<!--#include file="md5.asp"-->
<% function reg_check()
username=str_filter(request.Form("username"))
userpassword=md5(str_filter(request.Form("userpassword")))
email=str_filter(request.Form("email"))
question=str_filter(request.Form("question"))
answer=str_filter(request.Form("answer"))
turename=str_filter(request.Form("turename"))
scope=str_filter(request.Form("scope"))
id_card=str_filter(request.Form("id_card"))
sex=str_filter(request.Form("sex"))
address=str_filter(request.Form("address"))
zip=str_filter(request.Form("zip"))
phone=str_filter(request.Form("phone"))
qq=str_filter(request.Form("qq"))
if username<>""and userpassword<>""and question<>"" and answer<>"" and turename<>"" and id_card<>"" and sex<>"" and address<>"" and phone<>""and scope<>"" then
set rs=server.createobject("adodb.recordset")
rs.open "select * [bout_user] where turename='"&turename&"'",conn,1,3
if not rs.eof then
response.Write("<script language='javascript'>arert('此用户已存在,请重新输入!');</script>")
else
rs.addnew
rs("username")=username
rs("userpassword")=userpassword
rs("email")=email
rs("question")=question
rs("answer")=answer
rs("turename")=turename
rs("id_card")=id_card
rs("sex")=sex
rs("address")=address
rs("zip")=zip
rs("scope")=scope
rs("phone")=phone
rs("qq")=qq
rs.update
rs.close
set rs=nothing
session("username")=username
session("turename")=turename
session("password")=userpassword
response.Write("<script language='javascript'>arert('恭喜你会员注册成功!');window.location.href='../index.asp';</script>")
end if
else
response.Write("<script language='javascript'>arert('请将信息填写完整!');</script>")
end if
end function
%>
<%
if not isempty (request.Form("check")) then
if request.Form("username")<>""then
set rs=server.createobject("adodb.recordset")
rs.open "select username from [bout_user] where username='"&str_filter(request.Form("username"))&"'",conn,1,3
if rs.eof then
response.Write("<script language='javascript'>arert('此用户可以使用!');</script>")
else
response.Write("<script language='javascript'>arert('此用户已存在,请重新输入!');</script>")
end if
rs.close
set rs=nothing
else
response.Write("<script language='javascript'>arert('请输入用户名!');</script>")
end if
end if
if not isempty (request.Form("sumbit")) then
call reg_check()
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/mycss.css" rel="stylesheet" type="text/css">
<title>用户注册</title>
<style type="text/css">
<!--
.STYLE2 {
color: #666666;
font-weight: bold;
font-size: 11pt;
font-family: "宋体";
}
.STYLE4 {color: #019867; font-weight: bold; font-size: 11pt; font-family: "宋体"; }
.STYLE5 {color: #FF0000}
-->
</style>
<script language="JavaScript">
<!--
function IsDigit()
{
return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
function check()
{
if(checkspace(form1.username.value)) {
form1.username.focus();
alert("对不起,请填写用户名!");
return false;
}
if(checkspace(form1.userpassword.value) || form1.userpassword.value.length < 6 || form1.userpassword.value.length >20) {
form1.userpassword.focus();
alert("密码长度不能不能为空,在6位到20位之间,请重新输入!");
return false;
}
if(form1.userpassword.value != form1.userpassword1.value) {
form1.userpassword.focus();
form1.userpassword.value = '';
form1.userpassword1.value = '';
alert("两次输入的密码不同,请重新输入!");
return false;
}
if(form1.email.value.length!=0)
{
if (form1.email.value.charAt(0)=="." ||
form1.email.value.charAt(0)=="@"||
form1.email.value.indexOf('@', 0) == -1 ||
form1.email.value.indexOf('.', 0) == -1 ||
form1.email.value.lastIndexOf("@")==form1.email.value.length-1 ||
form1.email.value.lastIndexOf(".")==form1.email.value.length-1)
{
alert("Email地址格式不正确!");
form1.email.focus();
return false;
}
}
else
{
alert("Email不能为空!");
form1.email.focus();
return false;
}
if(checkspace(form1.quesion.value)) {
form1.quesion.focus();
alert("对不起,请填写密码提问!");
return false;
}
if(checkspace(form1.answer.value)) {
form1.answer.focus();
alert("对不起,请填写密码提问的答案!");
return false;
}
if(checkspace(form1.turename.value)) {
form1.turename.focus();
alert("对不起,请填写真实姓名!");
return false;
}
if(checkspace(form1.adress.value)) {
form1.adress.focus();
alert("对不起,请填写通讯地址!");
return false;
}
}
if(checkspace(form1.zip.value)) {
form1.zip.focus();
alert("对不起,请填写邮编!");
return false;
}
if(form1.zip.value.length!=6) {
form1.zip.focus();
alert("对不起,请正确填写邮编!");
return false;
}
if(checkspace(form1.phone.value)) {
form1.phone.focus();
alert("对不起,请留下您的联系电话!");
return false;
}
}
function checkspace(checkstr) {
var str = '';
for(i = 0; i < checkstr.length; i++) {
str = str + ' ';
}
return (str == checkstr);
}
//-->
</script>
</head>
<body>
<!--#include file="top.asp"-->
<table width="777" height="430" cellspacing="0" cellpadding="0" style="border:1.5px #3AB928
solid;border-width:0 1 1 1; margin-top:6px;" align="center">
<tr>
<td align="left">
<table width="98%" border="0">
<tr>
<td height="21"> </td>
<td width="165" align="right"><em><font color="#ff0000">*号为必填项,请认真填写</font></em></td>
</tr>
</table>
<form id="form1" name="form1" method="post" action="">
<table width="98%" cellpadding="4" cellspacing="0" style="border:4px solid #EAFCE6;">
<tr>
<td height="23" align="left"><span class="STYLE4">用户名和密码:</span></td>
</tr>
<tr bgcolor="#EAFCE6">
<td height="29" bgcolor="#EAFCE6" align="left"><font color="#CC0000">*</font> 用 户 名:
<input type="text" name="username" size="18" maxlength="20" onblur="check()">
<input type="button" name="check" value="检测用户" tabindex="50">
支持中文,不支持特殊符号如:*%#!-&%$</td>
</tr>
<tr>
<td height="30">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="180"><font color="#CC0000">*</font> 密 码:
<input type="userpassword" name="userpassword" size="12" maxlength="12" onblur="return check()"></td>
<td>请使用5--12位,不支持特殊符号如:*%#!-&%$</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#EAFCE6">
<td height="26">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="180"><font color="#CC0000">*</font> 确认密码:
<input name="userpassword1" type="password" size="12" maxlength="12" onblur="return check()"></td>
<td>请再输入一遍您上面填写的密码。</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="318"><font color="#CC0000">*</font> 电子邮箱:
<input type="text" name="email" size="25" maxlength="50" onblur="return check()"></td>
<td width="246"></td>
</tr>
</table>