日期:2014-05-17  浏览次数:20847 次

怎样限制信息发布的时间间隔?比如发布两次信息中间必须间隔1分钟
我做了一个信息发布系统,但是人家要求不能联系发布信息,发完一条信息至少间隔一分钟才能发第二条,该怎么做呢?请指教

------解决方案--------------------
Dim PostTime
PostTime = Request.Cookies( "PostTime ")
if PostTime <> " " then
dim a
a=datediff( "n ",PostTime,now()) //取得时间差
if a <2 then
response.write " <script language= 'javascript '> alert( '小于1分钟就不能发布信息 ');history.back(); </script> "
Resposne.end
end if
end if
Response.Cookies( "PostTime ") = Now()
Resposne.Cookies( "PostTime ").Expires=DateAdd( "d ",1,Date)
------解决方案--------------------
用Session记录一下发布的时间,然后和当前时间比较一下,如果超过一分钟,就显示发布的界面,没有一分钟就不显示

在显示的表单界面中这样写:
if DateDiff( "m ",Session( "LastPublishTime "),NOW())> 1 then
'显示表单
else
'不显示表单
Response.Write "对不起,请一分钟后再发表 "
end if