为什么不用输入准考证号和姓名就可以登录?

pbkok 2012-03-14 05:32:09
我下载了一个在线考试系统源代码 为什么不用输入准考证号和姓名就可以登录?


这个是login.asp源码

<html>
<head>
<title>用户登录</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="style.css" rel=stylesheet>
<style type="text/css">
<!--
a { color: #000000; text-decoration: none}
.bt { font-size: 9pt; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; height: 16px; width: 80px; background-color: #eeeeee; cursor: hand}
-->
</style>
</head>
<body background="images/bj.gif" link="#000000" vlink="#FF0000" alink="#000000">

<p align="center">
<img border="0" src="images/logo.gif" width="493" height="107">
<table width="350" border="1" cellspacing="0" cellpadding="0" align="center" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<tr bgcolor="#33CCFF">
<td colspan="2" width="346">
<div align="center">考生登录</div>
</td>
</tr>
<tr bgcolor="#F0F0F0">
<td colspan="2" width="346">
<blockquote>
<form method="GET" action="chklogin.asp" >
<p align="center">准考证号<input type="text" name="StudentID" size="16" maxlength="10"></p>
<p align="center">姓    名<input type="text" name="Name" size="16" maxlength="10"></p>
<p align="center">
考试科目
<select name="Subject">
<!-- #include file="connect.asp" -->
<%rs.Open "Select * From 试卷信息 Order By 创建日期 DESC", conn, 1,1
while not rs.eof%>

<option value="<%=rs("试卷名称")%>"><%=rs("试卷名称")%></option>
<%
rs.movenext
wend
rs.close%>
</select></p>

<div align="center">
<input type="submit" name="send" value="登录" >
<input type="reset" value="重写" >
</div>
</form>
</blockquote>
</td>
</tr>
<tr><td bgcolor="#F0F0F0" width="173">
<p align="center"><a href="readme.htm" class="bt"><font color="#000000">使用说明</font></a></p>
</td><td bgcolor="#F0F0F0" width="171">
<p align="center"><a href="adminlogin.htm" class="bt"><font color="#000000">管理登陆</font></a></td></tr>
</table>
<p align="center">作者:韩波       
指导教师:徐新农</p>
<p align="center">单位:物理工程学院电子信息工程专业</p>
<p align="center">2003.5.1</p>
</body>
</html>

chlkogin.asp源码

<%
StudentID=Request("StudentID")
Name=Request("Name")
Subject=Request("Subject")
if StudentID="" then %>
<script language=vbscript>
MsgBox "错误:请输入你的学号!"
location.href = "javascript:history.back()"
</script>
<%
end if
if Name="" then%><script language=vbscript>
MsgBox "错误:请输入你的姓名!"
location.href = "javascript:history.back()"
</script> <%
end if%>
<!-- #include file="connect.asp" -->
<%
rs.Open "Select * From 学生信息 where StudentID='"& StudentID &"'", conn,1,1%>
<%if rs.bof then %>
<script language=vbscript>
MsgBox "错误:此学号不存在!"
location.href = "javascript:history.back()"
</script>
<%
elseif Name<>rs("Name") then%>
<script language=vbscript>
MsgBox "错误:你的学号和你的姓名不一致,请查正!"
location.href = "javascript:history.back()"
</script>
<%end if
rs.close
rs.open "select * from 成绩表 where StudentID='"&StudentID&"' and 试卷名称='"&Subject&"'",conn,1,1

if not rs.eof then%>
<script language=vbscript>
MsgBox "错误:你已经参加过这一门的考试了!"
location.href = "javascript:history.back()"
</script>
<%else
session("logstatus")=1 '记录登陆状态
response.redirect "testpaper.asp?"&Request.QueryString
end if
conn.close
set rs=nothing%>

...全文
160 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
小孩快跑 2012-03-14
  • 打赏
  • 举报
回复
是不是你之前登录了,保存cookie啦!
吟月轻舞 2012-03-14
  • 打赏
  • 举报
回复
根据你的代码做了修改,注意几点:
asp需要在每个if分支上关闭数据库连接,否则多输入错误几次数据库连接也会满

if逻辑尽量清晰些,你原来的写法虽然也可以,但是出现错误很难排错

最后登录成功后跳转页面的参数不对
吟月轻舞 2012-03-14
  • 打赏
  • 举报
回复

<!-- #include file="connect.asp" -->
<%
StudentID=Request("StudentID")
Name=Request("Name")
Subject=Request("Subject")
session("logstatus")=0 '初始化登录状态
if StudentID="" then
response.write("<script language=vbscript>MsgBox ""错误:请输入你的学号!""location.href ='javascript:history.back()'</script>")
elseif Name="" then
response.write("<script language=vbscript>MsgBox ""错误:请输入你的姓名!""location.href ='javascript:history.back()'</script>")
else
rs.Open "Select * From 学生信息 where StudentID='"& StudentID &"'", conn,1,1
if rs.bof then
response.write("<script language=vbscript>MsgBox ""错误:此学号不存在!""location.href ='javascript:history.back()'</script>")
rs.close
elseif Name<>rs("Name") then
response.write("<script language=vbscript>MsgBox ""错误:你的学号和你的姓名不一致,请查正!""location.href ='javascript:history.back()'</script>")
rs.close
else
rs.close
rs.open "select * from 成绩表 where StudentID='"&StudentID&"' and 试卷名称='"&Subject&"'",conn,1,1
if not rs.eof then
response.write("<script language=vbscript>MsgBox ""错误:你已经参加过这一门的考试了!""location.href ='javascript:history.back()'</script>")
conn.close
else
session("logstatus")=1 '记录登陆状态
'注意此处,“Request.QueryString”你是要传递什么参数?正确的参数格式为 aaa.asp?参数名=参数值
response.redirect "testpaper.asp?"&Request.QueryString
conn.close
set rs=nothing
end if
end if
end if
%>
pbkok 2012-03-14
  • 打赏
  • 举报
回复
我看不出来那里是出错的原因!所以我就全复制上去了, 对了 我这是基于asp的
吟月轻舞 2012-03-14
  • 打赏
  • 举报
回复
标签没对上,代码不完整,逻辑混乱。。。。
porschev 2012-03-14
  • 打赏
  • 举报
回复

script 标签你都没对应上吧。。
tan598121925 2012-03-14
  • 打赏
  • 举报
回复
眼花了
吟月轻舞 2012-03-14
  • 打赏
  • 举报
回复
好好整理下你的代码逻辑吧,现在的状况只能用一团糟来形容

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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