自己使用的一套ASP网页计数器代码每次刷新都会增加访问数,帮忙看看加入怎样的代码才能防刷新计数?
自己使用的一套ASP网页计数器代码每次刷新都会增加访问数,帮忙看看在count.asp中加入怎样的代码才能防刷新计数?自己使用的ASP网页计数器代码coun.asp<!-...
自己使用的一套ASP网页计数器代码每次刷新都会增加访问数,帮忙看看在count.asp中加入怎样的代码才能防刷新计数?
自己使用的ASP网页计数器代码coun.asp
<!--#include file="inc/conn.asp"-->
<%
dim rs_hits
set rs_hits=server.CreateObject("adodb.recordset")
sql="select * from hits"
rs_hits.open sql,conn,1,3
rs_hits("hits")=rs_hits("hits")+1
rs_hits.update
hits=rs_hits("hits")
rs_hits.close
set rs_hits=nothing
conn.close
set conn=nothing
%>
document.write("<%= hits %>");
以上代码文件中涉及到的文件conn.asp(也许无用,仅列于此,供参考)
<%
On Error Resume Next '防暴库
Dim db,conn,connstr
db="data/#data_cnpn.mdb" '更改数据库名字
set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr
'设定每页显示留言数量
Dim listnum
listnum = 10
'过滤HTML代码
function HTMLEncode(fString)
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, CHR(32), " ")
fString = Replace(fString, CHR(34), """)
fString = Replace(fString, CHR(39), "'")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P'> ")
fString = Replace(fString, CHR(10), "<BR> ")
HTMLEncode = fString
end function
'检查输入email是否合法
function IsValidEmail(email)
Dim names
Dim name
Dim i
Dim c
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, "..") > 0 then
IsValidEmail = false
end if
end function
%> 展开
自己使用的ASP网页计数器代码coun.asp
<!--#include file="inc/conn.asp"-->
<%
dim rs_hits
set rs_hits=server.CreateObject("adodb.recordset")
sql="select * from hits"
rs_hits.open sql,conn,1,3
rs_hits("hits")=rs_hits("hits")+1
rs_hits.update
hits=rs_hits("hits")
rs_hits.close
set rs_hits=nothing
conn.close
set conn=nothing
%>
document.write("<%= hits %>");
以上代码文件中涉及到的文件conn.asp(也许无用,仅列于此,供参考)
<%
On Error Resume Next '防暴库
Dim db,conn,connstr
db="data/#data_cnpn.mdb" '更改数据库名字
set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr
'设定每页显示留言数量
Dim listnum
listnum = 10
'过滤HTML代码
function HTMLEncode(fString)
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, CHR(32), " ")
fString = Replace(fString, CHR(34), """)
fString = Replace(fString, CHR(39), "'")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P'> ")
fString = Replace(fString, CHR(10), "<BR> ")
HTMLEncode = fString
end function
'检查输入email是否合法
function IsValidEmail(email)
Dim names
Dim name
Dim i
Dim c
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, "..") > 0 then
IsValidEmail = false
end if
end function
%> 展开
展开全部
<%
dim rs_hits
set rs_hits=server.CreateObject("adodb.recordset")
sql="select * from hits"
rs_hits.open sql,conn,1,3
If IsNull(session("UsingCount")) Or session("UsingCount")="" Then
rs_hits("hits")=rs_hits("hits")+1
rs_hits.update
session("UsingCount")=True
End If
hits=rs_hits("hits")
rs_hits.close
set rs_hits=nothing
conn.close
set conn=Nothing
End If
%>
document.write("<%= hits %>");
——广东新碧图文信息技术工作室 WEB研发部 竭诚为您服务。
dim rs_hits
set rs_hits=server.CreateObject("adodb.recordset")
sql="select * from hits"
rs_hits.open sql,conn,1,3
If IsNull(session("UsingCount")) Or session("UsingCount")="" Then
rs_hits("hits")=rs_hits("hits")+1
rs_hits.update
session("UsingCount")=True
End If
hits=rs_hits("hits")
rs_hits.close
set rs_hits=nothing
conn.close
set conn=Nothing
End If
%>
document.write("<%= hits %>");
——广东新碧图文信息技术工作室 WEB研发部 竭诚为您服务。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询