ASP 防止重复刷新计数
求高手修改这个页面,要求访问者在2小时内刷新不会重复提取数据,只显示上一次提取(并删除掉)的数据。<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"...
求高手修改这个页面,要求访问者在2小时内刷新不会重复提取数据,只显示上一次提取(并删除掉)的数据。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>欢迎光临东方网点</title>
</head>
<body>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><%
Const ForReading = 1, ForWriting = 2
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
'读取文本文件中的所有行内容
Set MyFile = fso.OpenTextFile("D:\bak\gonggao\youhuiquan.txt", ForReading)
j=0
Do While Not MyFile.atEndOfStream
if j<>0 then
abc = abc + MyFile.ReadLine &","
else
edf = MyFile.ReadLine '这里得到了首行的内容
end if
j=j+1
loop
MyFile.Close
if j>0 then
Response.Write "<h1>领取成功!优惠券码为" &edf & ",请您存好!</h1>"
else
response.write "对不起,已无激活码可领取!"
end if
if j>1 then
abc=Left(abc,Len(abc)-1) '去掉最后一个符号
end if
'写入内容到文本文件中
Set MyFile = fso.OpenTextFile("D:\bak\gonggao\youhuiquan.txt", ForWriting, True)
StrQ=split(abc,",")
For i=LBound(StrQ) to UBound(StrQ)
MyFile.WriteLine StrQ(i)
next
MyFile.Close
%></td>
</tr>
</table>
</body>
</html> 展开
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>欢迎光临东方网点</title>
</head>
<body>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><%
Const ForReading = 1, ForWriting = 2
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
'读取文本文件中的所有行内容
Set MyFile = fso.OpenTextFile("D:\bak\gonggao\youhuiquan.txt", ForReading)
j=0
Do While Not MyFile.atEndOfStream
if j<>0 then
abc = abc + MyFile.ReadLine &","
else
edf = MyFile.ReadLine '这里得到了首行的内容
end if
j=j+1
loop
MyFile.Close
if j>0 then
Response.Write "<h1>领取成功!优惠券码为" &edf & ",请您存好!</h1>"
else
response.write "对不起,已无激活码可领取!"
end if
if j>1 then
abc=Left(abc,Len(abc)-1) '去掉最后一个符号
end if
'写入内容到文本文件中
Set MyFile = fso.OpenTextFile("D:\bak\gonggao\youhuiquan.txt", ForWriting, True)
StrQ=split(abc,",")
For i=LBound(StrQ) to UBound(StrQ)
MyFile.WriteLine StrQ(i)
next
MyFile.Close
%></td>
</tr>
</table>
</body>
</html> 展开
1个回答
展开全部
手机上没办法写,说下我的思路,用session或cookies保存之前提取的值并设过期时间2小时,再次提取先判断session或cookies是否过期
追问
是的亲,麻烦帮忙修改一下这个网页。我修改的总是报错。
追答
<%
If Request.Cookies("edf") Is Nothing Then
Const ForReading = 1, ForWriting = 2
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
'读取文本文件中的所有行内容
Set MyFile = fso.OpenTextFile("D:\bak\gonggao\youhuiquan.txt", ForReading)
j=0
Do While Not MyFile.atEndOfStream
if j<>0 then
abc = abc + MyFile.ReadLine &","
else
edf = MyFile.ReadLine '这里得到了首行的内容
end if
j=j+1
loop
MyFile.Close
if j>0 then
Response.Cookies("edf")=edf
Response.Cookies("edf").Expires= (now()+2/24)
Response.Write "<h1>领取成功!优惠券码为" &edf & ",请您存好!</h1>"
else
response.write "对不起,已无激活码可领取!"
end if
if j>1 then
abc=Left(abc,Len(abc)-1) '去掉最后一个符号
end if
'写入内容到文本文件中
Set MyFile = fso.OpenTextFile("D:\bak\gonggao\youhuiquan.txt", ForWriting, True)
StrQ=split(abc,",")
For i=LBound(StrQ) to UBound(StrQ)
MyFile.WriteLine StrQ(i)
next
MyFile.Close
Else
Response.Write "<h1>你已领取过!优惠券码为" & Request.Cookies("edf") & ",请您存好!</h1>"
End if
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询