关于投票的问题
我想做到一个ip投票一次后,在tpip表中存储其ip和时间,2分钟只能不能再进行投票.现在遇到一个问题就是.如果他是第一次投票,该如何判断.我用total=rs1.recordcount无法得到记录数目
<!--#include file= "conn1.asp "-->
<%
id=trim(request.querystring( "userid "))
username=trim(request.querystring( "username "))
Caption=trim(request.querystring( "caption "))
come_ip = Request.ServerVariables( "HTTP_X_FORWARDED_FOR ")
if come_ip = " " then
come_ip=Request.ServerVariables( "remote_addr ")
end if
if instr(come_ip, " ' ")> 0 then
come_ip= "0.0.0.0 "
end if
'+==========================================================+
'+==========================================================+
set rs1=server.createobject( "adodb.recordset ")
sql = "select * from tpip where ip= ' " & come_ip & " ' "
rs1.open sql,conn,1,1
if not rs1.eof then
total=rs1.recordcount
response.write(total)
if abs(DateDiff( "n ", Now, rs1( "dtime ")))= <2 then
response.write( "错误信息 ")
else if abs(DateDiff( "n ", Now, rs1( "dtime ")))=> 2 or total <=0 then
set rs2=server.createobject( "ADODB.recordset ")
sql= "select * from Dv_bbs1 where postuserid= " &id& "and dateandtime=# " & caption & "# "
rs2.open sql,conn,1,2
rs2( "isvote ")=rs2( "isvote ")+1
response.write "您已经为 " & username & "投票成功 "
rs2.update
rs2.close
end if
end if
rs1.update
rs1.close
end if
set rs=server.createobject( "ADODB.recordset ")
rs.Open "select * from tpip ",conn,1,3
if not rs.eof and not rs.bof then
rs.addnew
rs( "ip ")=come_ip
rs( "dtime ")=now()
rs.update
rs.close
end if
------解决方案--------------------如果用total=rs1.recordcount无法取出正确值的话,可以考虑使用sql = "select count(id) as expr1 from tpip where ip= ' " & come_ip & " ' "来实现。取值的时候取total=rs1( "expr1 ")即可。
------解决方案--------------------给个session 如果投了票就给它个值, 这样就好恶劣
------解决方案--------------------select count(ip) from tpip where ip= 'IP地址 ' and datediff(minute,时间,now())> 2
------解决方案--------------------可考慮用COOKIE
------解决方案--------------------俺以前也这么限制过,可有人更狠 用ADSL拨号+按键精灵