首页 新闻 会员 周边 捐助

使用的ASP网页计数器代码每次刷新都会增加访问数,帮忙看看加入怎样的代码才能防刷新计数?

0
悬赏园豆:10 [已解决问题] 解决于 2010-10-11 17:08

自己使用的一套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, ">", "&gt;")
fString
= replace(fString, "<", "&lt;")
fString
= Replace(fString, CHR(32), "&nbsp;")
fString
= Replace(fString, CHR(34), "&quot;")
fString
= Replace(fString, CHR(39), "&#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
%
>

 

雪晶的主页 雪晶 | 初学一级 | 园豆:0
提问于:2010-10-09 21:41
< >
分享
最佳答案
0

网上找些asp实现的现成例子研究。

收获园豆:10
Astar | 高人七级 |园豆:40805 | 2010-10-11 09:56
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册