当前位置: 首页 > 图文教程 > 网络编程 > ASP > 用ASP开发一个在线考试程序(四)

ASP
ASP调用ORACLE存储过程并返回结果集
用ASP实现网页BBS
关于Global.asa文件的深入研究与session变量失效提示的具体方法
简易ASP+注册系统
防护手册:如何防止ASP木马在服务器上运行
用Visual Basic实现多画面播放功能之二
如何增强ASP程序性能(1)
如何增强ASP程序性能(2)
如何增强ASP程序性能(3)
ASP备份数据库
二十八条改善 ASP 性能和外观的技巧
在Form域中Post大于100K的数据
如何使用ASP制作模似动态生长的表单?
Microsoft IIS 真的如此「不安全」吗?(1)
Microsoft IIS 真的如此「不安全」吗?(2)
Microsoft IIS 真的如此「不安全」吗?(3)
Microsoft IIS 真的如此「不安全」吗?(4)
Microsoft IIS 真的如此「不安全」吗?(5)
关于页面和代码分离
ServerVariables 对路径的操作

用ASP开发一个在线考试程序(四)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 113 ::
收藏到网摘: n/a

  Checkuser.asp
  在应用程序的开始,访问者键入了他们的口令之后,他们的细节被指向了一页,如sendregister.asp,来检验一下具体
的用户名和口令在数据库中是否存在。
sql_check = "select count(*) from loginuser where username ='" & _
username &"' and password = '" & useremail &"'"
Set RS_check = Application("Conn").Execute(sql_check)
If RS_check(0) < > 0 Then
Session("username") = request.form("username")
response.redirect "default.asp"
End If
If RS_check(0) = 0 Then
Session("error") = "WRONG USER NAME OR PASSWORD"
response.redirect "index.asp"
End If
  sql命令检查一个特定的用户是否已经注册了。如果返回值为0,就表明用户名或email 无效,将用户引导回注册页。
如果是会员,就被引导到default.asp 页。这一次又用到了替换函数,以保证如果会员键入了‘ (单引号),就要用''
(双引号)来替换。
username = replace(request.form("username"),"'","''")
useremail = replace(request.form("password"),"'","''")
选择一个测验
Default.asp
  一旦成功登录,就出现第二个界面,提供会员可以选择的测验科目的列表。在本例中,我们有HTML 和DHTML ,当然可
以增加表格以提高主题数。Default.asp 要求表格安装一个下拉菜单,其中包含主题的列表。查询数据库,从试卷的表格
中搜集两个域。
sql_papers = "select *id, topic from paper sort order by topic asc"
SET RS_papers = Application("Conn").Execute(sql_papers)
  为了在下拉菜单中显示结果,使用以下代码:
SELECT size=1 name=select1 onchange="msec(document.form1._
select1.options[document.form1.select1.selectedIndex].value);" >
< option value="0" >Select the examination
< %Do while not RS_papers.EOF% >
< option value="< %=RS_papers("id")% >" >< %=lcase(RS_papers("topic"))% >< /OPTION >
< %
RS_papers.MoveNext
Loop
% >
  msec函数在X值的基础上调用 redirect.asp,把查询字符串: ?x 的值作为下拉菜单中被选择的项的值。
function msec(x)
{if (x==0)
{ alert("Please select any one of the Examinations")
}
else
{ location.href="redirect.asp?section=" + x
}
}