当前位置:编程学习 > asp >>

下面代码是ASP投票系统的代码,这是同一IP只能投一票,帮我改成同一IP20分钟内只能能投1票,谢谢

<% Dim VoTeid,HostUrl,Zuid VoTeid = Int(CHECKSTR(trim(Request.QueryString("VoTeid")))) HostUrl=Request.ServerVariables("HTTP_REFERER") Zuid=Cint(session("zhi_rui_v_userID")) if VoTeid="" then Call Alert ("不允许值为空,请选择后提交!",HostUrl) End if Rem 获取IP function getIP() getIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR") If getIP = "" Then getIP = Request.ServerVariables("REMOTE_ADDR") end if end function Rem 投票开关 If power=0 then Call Alert ("暂时无法投票!",HostUrl) End if function ZhiIP(vid,ip) sql="Select * from zhi_rui_v_Vo where Voteid="&vid&" and Hostip='"&ip&"'" Set rs=conn.execute(sql) if not rs.eof then ZhiIP=true else ZhiIP=false end if end function if ZhiIP(Voteid,getIP())=true then Call Alert ("你的IP:"&getIP()&"已经投票,不能继续投票!",HostUrl) end if sql="update zhi_rui_v_po set Amio=Amio+1 where id="&Voteid conn.execute(sql) sql="insert into zhi_rui_v_Vo(Voteid,Userid,Hostip,HostAd,HostUl,AddTime) values("&Voteid&","&Zuid&",'"&getIP()&"','来源','"&HostUrl&"',#"&now()&"#)" conn.execute(sql) Call Alert("投票成功,感谢您宝贵的一票!请填写信息参与抽奖","/voterinfo/login.asp") %>
补充:20分钟后此IP还可以继续投票
追问:ACCESS的呢不行啊,现在可以不限制的投票了
是不是<20啊?
答案:我不知道你用的什么数据库如果是sqlserver的话把
sql语句修改成
加上了 datediff(mi,AddTime,GETDATE()) >20  这个条件
access数据库
datediff(‘n‘,AddTime,now()) >20
sql="Select * from zhi_rui_v_Vo where Voteid="&vid&" and Hostip='"&ip&"' and datediff(mi,AddTime,GETDATE()) >20 "

就可以了
其他:联系 1997124 

上一个:</div><font size="2">{$NewaspLabel_Bottom}</font>是什么意思。 这是asp网页源码。求解~
下一个:我的网站是用asp.net开发的,利用了伪静态的技术,空间租的是VPS,请问如果设置IIS才能让网站跑起来呢?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,