cookie 实现一个IP一天投5次票,以下代码我写的是只投一次求高手修改
cookie 实现一个IP一天投5次票,
ASP代码,hit.asp
<%
if Request.Cookies("firstname")="Alex" then
response.write("你已经投票")
else
response.Cookies("firstname") = "Alex"
response.Cookies("firstname").Expires =DateAdd("h",1,now())
fname=Request.Cookies("firstname")
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("data/guestbook.mdb")
hotid=request.QueryString("hotid")
exec="update guest set hot=hot+1 where id="&hotid
conn.execute exec
conn.close
set conn=nothing
response.write "记录添加成功!"
response.write(hotid)
end if
%>
想在这里加上一个IP一天只能投票5次,
if Request.Cookies("firstname")="Alex" then
判断投票次数,够5次的,
response.write("你已经投票")
不够,就执行下面的的else代码,
------解决方案--------------------<%
if Request.Cookies("firstname")>5 then
response.write("你已经投票")
else
response.Cookies("firstname") = response.Cookies("firstname")+1
response.Cookies("firstname").Expires =DateAdd("h",1,now())
fname=Request.Cookies("firstname")
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("data/guestbook.mdb")
hotid=request.QueryString("hotid")
exec="update guest set hot=hot+1 where id="&hotid
conn.execute exec
conn.close
set conn=nothing
response.write "记录添加成功!"
response.write(hotid)
end if
%>
------解决方案--------------------if CInt(Request.Cookies("firstname"))>5 then
------解决方案--------------------清除cookie 一天想怎么投就怎么投
------解决方案--------------------清除cookie 一天想怎么投就怎么投
這有難度
------解决方案--------------------基本上对投票限制是针对IP的,很少有使用cookie 实现的,因为这样会造成8楼所说的情况出现
http://topic.csdn.net/u/20120430/15/093f03f5-f6dd-458b-a616-c7e7c0d61c23.html
参考下看看对你有没有帮助