急,急,急,asp投票限制,每个两小时才能投一票,请教高手帮忙看下下面的代码
DimrefuseTimerefuseTime=2ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR")Ifip=""The...
Dim refuseTime
refuseTime=2
ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip = "" Then ip = Request.ServerVariables("REMOTE_ADDR")
set rs=Server.CreateObject("ADODB.recordset")
sql="Select ip,tptime from vote Where ip='"&ip&"' and tptime='"&tptime&"'"
response.Write(sql)
conn.execute(sql)
if datediff("h",tpime,now())<"&refuseTime&" then
rs.open sql,conn,1,3
if not rs.eof then
response.write"<SCRIPT language=JavaScript>alert('提示:您已投过票,谢谢您的参与,每两小时只能投一票,请稍候再来');location.href='Index.Asp';</SCRIPT>"
end if
else
P_UserName=request.QueryString("P_UserName")
sqlmm="update [Ejz_HuoDong_BaoMing] set P_Count=P_Count+1 where P_UserName='"&P_UserName&"'"
conn.execute(sqlmm)
response.Write(sqlmm) sqlnn="insert into [vote] (ip,tptime) Values ('"&ip&"','"&now()&"') "
conn.execute(sqnn)
response.Write(sqnn)
Response.Write "<SCRIPT>alert('谢谢您的关注,投票成功!');this.location.href='javascript:window.close()';</SCRIPT>"
end if 展开
refuseTime=2
ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip = "" Then ip = Request.ServerVariables("REMOTE_ADDR")
set rs=Server.CreateObject("ADODB.recordset")
sql="Select ip,tptime from vote Where ip='"&ip&"' and tptime='"&tptime&"'"
response.Write(sql)
conn.execute(sql)
if datediff("h",tpime,now())<"&refuseTime&" then
rs.open sql,conn,1,3
if not rs.eof then
response.write"<SCRIPT language=JavaScript>alert('提示:您已投过票,谢谢您的参与,每两小时只能投一票,请稍候再来');location.href='Index.Asp';</SCRIPT>"
end if
else
P_UserName=request.QueryString("P_UserName")
sqlmm="update [Ejz_HuoDong_BaoMing] set P_Count=P_Count+1 where P_UserName='"&P_UserName&"'"
conn.execute(sqlmm)
response.Write(sqlmm) sqlnn="insert into [vote] (ip,tptime) Values ('"&ip&"','"&now()&"') "
conn.execute(sqnn)
response.Write(sqnn)
Response.Write "<SCRIPT>alert('谢谢您的关注,投票成功!');this.location.href='javascript:window.close()';</SCRIPT>"
end if 展开
2个回答
展开全部
<%
Dim refuseTime
refuseTime=2 '控制最小投票间隔,单位小时
ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip = "" Then
ip = Request.ServerVariables("REMOTE_ADDR")
End If
set rs=Server.CreateObject("ADODB.recordset")
sql="Select ip,tptime from vote Where ip='"&ip&"' and DATEDIFF(hh,tptime,'"&Now()&"')<"&refuseTime
conn.execute(sql)
rs.open sql,conn,1,3
if not rs.eof then
response.write"<SCRIPT language=JavaScript>alert('提示:您已投过票,谢谢您的参与,每"&refuseTime&"小时只能投一票,请稍候再来');location.href='Index.Asp';</SCRIPT>"
else
P_UserName=request.QueryString("P_UserName")
sqlmm="update [Ejz_HuoDong_BaoMing] set P_Count=P_Count+1 where P_UserName='"&P_UserName&"'"
conn.execute(sqlmm)
response.Write(sqlmm) sqlnn="insert into [vote] (ip,tptime) Values ('"&ip&"','"&now()&"') "
conn.execute(sqnn)
response.Write(sqnn)
Response.Write "<SCRIPT>alert('谢谢您的关注,投票成功!');this.location.href='javascript:window.close()';</SCRIPT>"
end if
%>
Dim refuseTime
refuseTime=2 '控制最小投票间隔,单位小时
ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip = "" Then
ip = Request.ServerVariables("REMOTE_ADDR")
End If
set rs=Server.CreateObject("ADODB.recordset")
sql="Select ip,tptime from vote Where ip='"&ip&"' and DATEDIFF(hh,tptime,'"&Now()&"')<"&refuseTime
conn.execute(sql)
rs.open sql,conn,1,3
if not rs.eof then
response.write"<SCRIPT language=JavaScript>alert('提示:您已投过票,谢谢您的参与,每"&refuseTime&"小时只能投一票,请稍候再来');location.href='Index.Asp';</SCRIPT>"
else
P_UserName=request.QueryString("P_UserName")
sqlmm="update [Ejz_HuoDong_BaoMing] set P_Count=P_Count+1 where P_UserName='"&P_UserName&"'"
conn.execute(sqlmm)
response.Write(sqlmm) sqlnn="insert into [vote] (ip,tptime) Values ('"&ip&"','"&now()&"') "
conn.execute(sqnn)
response.Write(sqnn)
Response.Write "<SCRIPT>alert('谢谢您的关注,投票成功!');this.location.href='javascript:window.close()';</SCRIPT>"
end if
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询