只允许用户在某时段访问网站的asp程序如何编写?

来源:百度知道 编辑:UC知道 时间:2024/05/24 22:50:19
我要编写一段只允许用户在某时段访问网站的asp程序,数据库里面“starttime”字段为开始允许访问的时间,“endtime”字段为结束访问的时间,数据类型均为时间时期型,“Error.asp”为网站非开放访问时段的错误提示页面。
我编写的程序如下:
nowtime=time()
if rs("starttime")<ri.("endtime") then
if nowtime<rs("starttime") or nowtime>rs.("endtime") then
response.write "<script>window.location ='Error.asp'</script>"
end if
else
if nowtime>rs("starttime") or nowtime<rs.("endtime") then
response.write "<script>window.location ='Error.asp'</script>"
end if
end if
执行后,无法显示该网页:
错误类型:
Microsoft VBScript 编译器错误 (0x800A03F2)
缺少标识符
/law0408/Record.asp, line 14, column 22
if rs("starttime")<rs.("endtime") then
---------------------^
请教各位高手,这是什么问题?或者帮我重新编写一下?
为我解决问题的,再追加50分!

兄弟的思路是对的!
只是和我一样 不够细心(嘿嘿!)

总共有三个

第一个:if rs("starttime")<ri.("endtime") then

我认为是if rs("starttime")<rs("endtime") then

第二个:if nowtime<rs("starttime") or nowtime>rs.("endtime") then
同上 改为rs("endtime")

第三个:if nowtime>rs("starttime") or nowtime<rs.("endtime") then
和第二个一样

嘿嘿 我以前的主管说我不够细心 现在好些了 希望兄弟也再细心点 !

rs . ("endtime") then
没点吧
if nowtime>rs("starttime") and nowtime<rs("endtime")then
......
else
response.write "<script>window.location ='Error.asp'</script>"
end if

晕,搞得这么复杂,直接用SQL语句查询是否属于可访问时间段就行了,

select * form 表 where '#"&now()&"#' between starttime and endtime

或者直接写到网页中:
<%
if time()<#12:00:00# then
response.write "可