为什么注册页面,什么都不写,点击提交,照样能注册成功呢?

biancheng258 2009-10-19 08:10:12
为什么注册页面,什么都不写,点击提交,照样能注册成功呢,为什么不走检测输入文本框(用户名、密码等)的check11( )函数呢?

这是我的注册文件:

<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<!--#Include File="WrSky_Sql.Asp"-->
<%dim action,username
action=request.QueryString("action")%>
<html><head><title><%=webname%>--新用户注册</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">


<script language=JavaScript>
function IsDigit()
{
return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
function check11()
{
if(
document.userinfo.username.value.length < 4||
document.userinfo.username.value.length >20) {
document.userinfo.username.focus();
alert("用户名长度不能为空,在4位到20位之间,请重新输入!");
return false;
}

if(checkspace(document.userinfo.userpassword.value) || document.userinfo.userpassword.value.length < 6 || document.userinfo.userpassword.value.length >20) {
document.userinfo.userpassword.focus();
alert("密码长度不能为空,在6位到20位之间,请重新输入!");
return false;
}
if(document.userinfo.username.value==document.userinfo.userpassword.value)
{
alert("为了安全,用户名与密码不应该相同,请重新输入密码!")
document.userinfo.userpassword.focus()
return false;
}
if(document.userinfo.userpassword.value != document.userinfo.userpassword1.value) {
document.userinfo.userpassword.focus();
document.userinfo.userpassword.value = '';
document.userinfo.userpassword1.value = '';
alert("两次输入的密码不同,请重新输入!");
return false;
}
}



function checkspace(checkstr) {
var str = '';
for(i = 0; i < checkstr.length; i++) {
str = str + ' ';
}
return (str == checkstr);
}
//-->
</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onMouseOver="window.status='【<%=webname%>】<%=weburl%> 如果您喜欢本站,别忘了把本站介绍给您的好友哦!:)';return true">
<!--#include file="include/header.asp"-->
<%select case action

<%case "yes"%>
<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF" bordercolor="#FFFFFF">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<p><font color="#FF3300"><b>请您务必详细填写您的信息,并核对无误。<br>
未经您的允许,您的个人信息对外保密。(带 <font color=red>**</font> 号为必填项) </b></font></p>
<form name=userinfo method=post action=reg.asp?action=save>
<table width="80%" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC" align="center">
<tr>
<td height=15 colspan=2 bgcolor="#f1f1f1">
<font color="#FF3300">>> 用户名和密码</font>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>用 户 名:</td>
<td width=70% class=pad>
<input class="wenbenkuang" name="username" type="text" id="username" maxLength="18">
<font color=red>**</font> 支持中文,不支持特殊符号如:*%#!-&%$</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>密  码:</td>
<td class=pad>
<input class="wenbenkuang" name="userpassword" type="password" id="userpassword" maxLength="18">
<font color=red>**</font> 不支持特殊符号如:*%#!-&%$</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>确认密码:</td>
<td class=pad>
<input class="wenbenkuang" name="userpassword1" type="password" id="userpassword1" maxLength="18">
<font color=red>**</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>电子邮箱:</td>
<td class=pad>
<input class="wenbenkuang" name="useremail" type="text" id="useremail">
<font color=red>**</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2" valign="middle" bgcolor="#f1f1f1"><font color="#FF3300">>> 用户详细资料</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>您的真实姓名:</td>
<td class=pad>
<input class="wenbenkuang" name="userzhenshiname" type="text" id="userzhenshiname" size="10">
<font color=red>**</font>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>姓  别:</td>
<td class=pad>
<input type=radio name=sex id=Select1 value=0 checked>男
<input type=radio name=sex id=Select1 value=1>女
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>通讯地址:</td>
<td class=pad>
<input class="wenbenkuang" name="shouhuodizhi" type="text" id="shouhuodizhi" size="40" maxlength="30">
<font color=red>**</font>
</td>
</tr>

<tr bgcolor="#FFFFFF">
<td width=30% align=right>联系电话:</td>
<td class=pad>
<input class="wenbenkuang" name="usertel" maxlength="18" type="text" id="usertel">
<font color=red>**</font>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>QQ:</td>
<td class=pad>
<input class="wenbenkuang" name="qq" maxlength="18" type="text" id="qq">
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>密码提示问题:</td>
<td class=pad>
<input class="wenbenkuang" name="quesion" type="text" id="quesion" size="40" maxlength="30">

</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>提示问题答案:</td>
<td class=pad>
<input class="wenbenkuang" name="answer" type="text" id="answer" size="40" maxlength="30">

</td>
</tr>

<tr bgcolor="#FFFFFF">
<td width=20% align="right"></td>
<td class=pad>
<input class="go-wenbenkuang" onClick="return check11();" type=submit name="submit" value=" 提交信息 ">
<input class="go-wenbenkuang" onclick="ClearReset()" type=reset name="Clear" value=" 重新填写 ">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr></table>

<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr>
<td bordercolor="#FFFFFF" bgcolor="#FFFFFF">
<%case "save"%>
<!--#include file="md5.asp"-->
<%call saveuser()%>
<%
end select%>
<%
sub saveuser()
dim rsrec,strgift,stradd,strresult
if session("regtimes")=1 then
response.Write "<table width=760 border=0 cellspacing=0 cellpadding=0 align=center><tr><td height=300 align=center><font color=red>对不起,您刚注册过用户,请稍后再进行注册!</font></td></tr></table>"
response.End
end if

set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [admin] where (UsereMail='"&trim(request("useremail"))&"' or admin='"&trim(request("username"))&"')",conn,1,1
if not rs.eof and not rs.bof then
call usererr()
rs.close
else
rs.close

set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [admin]",conn,1,3
rs.addnew
rs("admin")=trim(request("username"))
rs("UserPassword")=md5(trim(request("userpassword")))
rs("UsereMail")=trim(request("useremail"))
'rs("UserQuesion")=trim(request("quesion"))
'rs("UserAnswer")=md5(trim(request("answer")))
rs("realname")=trim(request("userzhenshiname"))
rs("dizhi")=trim(request("shouhuodizhi"))

rs("UserMobile")=trim(request("usertel"))
'rs("userqq")=trim(request("qq"))
rs("rank")=3
rs("adddate")=now()
rs("LastLogin")=now()
rs("UserLogins")=1


rs("usersex")=trim(request("sex"))
rs("UserLastIP")=Request.ServerVariables("REMOTE_ADDR")


rs.update

rs.close
set rs=nothing

%>
<table width=760 border=0 align=center cellpadding=0 cellspacing=1 bgcolor=<% = bgclr1 %>>
<tr><td height=100 bgcolor=<% = bgclr4 %>>
<table width=700 border=0 align=center cellpadding=0 cellspacing=0>
<tr><td height=80 bgcolor=<% = bgclr4 %>><font color=#FF0000>用户注册成功<br></font>
恭喜<% = request.Cookies("timesshop")("username") %>,您已注册成为[<% = webname %>]正式用户,请从首页登陆<br><br>

·<a href=index.asp>返回首页</a></td></tr></table>
</td></tr></table>
<%
end if
end sub


sub usererr()
response.write "<table width=760 align=center border=0 cellspacing=0 cellpadding=0 class=table-zuoyou bordercolor=#CCCCCC><tr><td bordercolor=#FFFFFF bgcolor=#FFFFFF align=center>"
response.write "<table width=450 border=0 align=center cellpadding=2 cellspacing=0><tr><td height=260>"
response.write "<p>· <font color=red>用户注册失败!</font></p><p>· 您输入的用户名或e-mail地址已存在,请返回重新输入!</p><p>· <a href=javascript:history.go(-1)>返回上一页</a></p> </td></tr></table></td></tr></table>"
end sub
%>
</td>
</tr>
</table>
<!--#include file="include/footer.asp"-->
</body>
</html>
...全文
147 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ilxl520 2009-10-19
  • 打赏
  • 举报
回复
<input class="go-wenbenkuang" onClick="return check11();" type=submit name="submit" value=" 提交信息 ">

事件应该写在<form >里
hookee 2009-10-19
  • 打赏
  • 举报
回复
以下代码测试下来,不填用户名密码不能递交。其他字段因为check11()中没有检测,所以不填可以递交

<script language=JavaScript>
function IsDigit()
{
return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
function check11()
{
if(
document.userinfo.username.value.length < 4||
document.userinfo.username.value.length >20) {
document.userinfo.username.focus();
alert("用户名长度不能为空,在4位到20位之间,请重新输入!");
return false;
}

if(checkspace(document.userinfo.userpassword.value) || document.userinfo.userpassword.value.length < 6 || document.userinfo.userpassword.value.length >20) {
document.userinfo.userpassword.focus();
alert("密码长度不能为空,在6位到20位之间,请重新输入!");
return false;
}
if(document.userinfo.username.value==document.userinfo.userpassword.value)
{
alert("为了安全,用户名与密码不应该相同,请重新输入密码!")
document.userinfo.userpassword.focus()
return false;
}
if(document.userinfo.userpassword.value != document.userinfo.userpassword1.value) {
document.userinfo.userpassword.focus();
document.userinfo.userpassword.value = '';
document.userinfo.userpassword1.value = '';
alert("两次输入的密码不同,请重新输入!");
return false;
}
}

function checkspace(checkstr) {
var str = '';
for(i = 0; i < checkstr.length; i++) {
str = str + ' ';
}
return (str == checkstr);
}
//-->
</script>

<table width="760" align="center" border="0" cellspacing="0" cellpadding="0" class="table-zuoyou" bordercolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF" bordercolor="#FFFFFF">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<p> <font color="#FF3300"> <b>请您务必详细填写您的信息,并核对无误。 <br>
未经您的允许,您的个人信息对外保密。(带 <font color=red>** </font> 号为必填项) </b> </font> </p>
<form name=userinfo method=post action=reg.asp?action=save>
<table width="80%" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC" align="center">
<tr>
<td height=15 colspan=2 bgcolor="#f1f1f1">
<font color="#FF3300">>> 用户名和密码 </font>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>用 户 名: </td>
<td width=70% class=pad>
<input class="wenbenkuang" name="username" type="text" id="username" maxLength="18">
<font color=red>** </font> 支持中文,不支持特殊符号如:*%#!-&%$ </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>密  码: </td>
<td class=pad>
<input class="wenbenkuang" name="userpassword" type="password" id="userpassword" maxLength="18">
<font color=red>** </font> 不支持特殊符号如:*%#!-&%$ </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>确认密码: </td>
<td class=pad>
<input class="wenbenkuang" name="userpassword1" type="password" id="userpassword1" maxLength="18">
<font color=red>** </font> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>电子邮箱: </td>
<td class=pad>
<input class="wenbenkuang" name="useremail" type="text" id="useremail">
<font color=red>** </font> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2" valign="middle" bgcolor="#f1f1f1"> <font color="#FF3300">>> 用户详细资料 </font> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>您的真实姓名: </td>
<td class=pad>
<input class="wenbenkuang" name="userzhenshiname" type="text" id="userzhenshiname" size="10">
<font color=red>** </font>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>姓  别: </td>
<td class=pad>
<input type=radio name=sex id=Select1 value=0 checked>男
<input type=radio name=sex id=Select1 value=1>女
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>通讯地址: </td>
<td class=pad>
<input class="wenbenkuang" name="shouhuodizhi" type="text" id="shouhuodizhi" size="40" maxlength="30">
<font color=red>** </font>
</td>
</tr>

<tr bgcolor="#FFFFFF">
<td width=30% align=right>联系电话: </td>
<td class=pad>
<input class="wenbenkuang" name="usertel" maxlength="18" type="text" id="usertel">
<font color=red>** </font>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>QQ: </td>
<td class=pad>
<input class="wenbenkuang" name="qq" maxlength="18" type="text" id="qq">
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>密码提示问题: </td>
<td class=pad>
<input class="wenbenkuang" name="quesion" type="text" id="quesion" size="40" maxlength="30">

</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width=30% align=right>提示问题答案: </td>
<td class=pad>
<input class="wenbenkuang" name="answer" type="text" id="answer" size="40" maxlength="30">

</td>
</tr>

<tr bgcolor="#FFFFFF">
<td width=20% align="right"> </td>
<td class=pad>
<input class="go-wenbenkuang" onClick="return check11();" type=submit name="submit" value=" 提交信息 ">
<input class="go-wenbenkuang" onclick="ClearReset()" type=reset name="Clear" value=" 重新填写 ">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr> </table>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧