Access为后台数据库的网站统计系统
一个能对访问者进行编号、记录访问次数、IP、时间的统计制作实例 我以ACCESS库为例子,其实用SQL SERVER库也只要改一下链接库的语句就得啦,库结构如下 库文件名: CONT.ASP 本来是CONT.MDB但在建好后把扩展名改为了ASP,以防库被下载。 表名:tab 字段名 数
一个能对访问者进行编号、记录访问次数、IP、时间的统计制作实例
我以ACCESS库为例子,其实用SQL SERVER库也只要改一下链接库的语句就得啦,库结构如下
库文件名: CONT.ASP 本来是CONT.MDB但在建好后把扩展名改为了ASP,以防库被下载。
表名:tab
字段名 数据类型 说明
ID 自动编号 访客的编号
IP 文本 用于记录访客的IP
dat1 日期时间 用于记录访客最后访问的时间
dat 日期时间 用于记录访客第一次访问的时间
CS 数字,整型 用于记录访客访问次数
程序很简单,只有两个文件,dispcont.asp 用于显示统计结果,contpage.asp用于统计信息,
先看看CONTPAGE.ASP 是乍么统计的,代码如下:
Set Conn=Server.CreateObject("ADODB.Connection")
Connstr="DBQ="+server.mappath("cont.asp")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Conn.Open connstr ‘’*****以上语句用于连接库,cont.asp是库文件名。
keren=request.cookies("keren") ‘’读取cookies,cookies的名为:“keren”,哈哈。。阿余的E文学的臭,只懂用拼音啦。
if keren="" then ‘’判断cookees是不是空,如果是空,那么肯定是新朋友啦,否则是老朋友。
sql="SELECT * FROM tab where id=-1"
set rs=server.createobject("ADODB.Recordset")
rs.Open sql,conn, 1, 3
rs.addnew ‘’如果是新访客的话,在库中新增一条记录。
rs("cs")=1 ‘’记下访问次数为1
rs("ip")=request.servervariables("remote_addr") ‘’记下IP,
rs("dat")=now ‘’记下当前的日期时间,
rs("dat1")=date ‘’记下当前的日期,以后用来做第一次访问的日期,
response.cookies("keren")=rs("id") ‘’写入一个cookies,内容就和ID一样。
response.cookies("keren").expires=date+365 ‘’设置cookies的有效日期从现在开始,365天,
else ‘’以上是新朋友的处理办法,对老朋友怎么办呢?看下面的:
sql="SELECT * FROM tab where id="&keren ‘’到库中去找出我们老朋友的记录
set rs=server.createobject("ADODB.Recordset")
rs.Open sql,conn, 1, 3
rs("cs")=rs("cs")+1 ‘’好啦,找到啦,把访问次数加上1
rs("ip")=request.servervariables("remote_addr") ‘’看看他的IP是多少了,记下来。
rs("dat")=now ‘’记下现在的时间,也就是最后一次访问的时间,
response.cookies("keren")=rs("id") ‘’再把cookies写进去,我不知这句是否多余,没有试。
response.cookies("keren").expires=date+365 ‘’设置cookies过期时间,免得一年到了我就不认得他了。
end if
rs.update ‘’该记的都记下了,更新库吧。
rs.close ‘’关闭recordset对象。
set conn=nothing ‘’释放conn,我还是认为connection要随开随关才对,放到SESSION中我认为最不可取。4
%>
好啦,记录就做好啦,有二十几行代码,很简单的一个小程序,程序写好了,怎么放到页面中呢?很简单,在首页上随便找个地方,加上这行代码:就行了。
接下来就是把记录显示出来。
文件名:dispcont.asp , 请看代码:
Set Conn=Server.CreateObject("ADODB.Connection")
Connstr="DBQ="+server.mappath("cont.asp")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
Conn.Open connstr ‘’*****以上语句用于连接库,cont.asp是库文件名。
page3=request("pag")
if page3="" then page3=session("contpag") ‘’分页数,当前分页
if page3="" then page3="1"
pa=request("pa")
if pa="" then pa=session("contpa") ‘’每页显示数
if pa="" then pa=15 ‘’默认每页显示15条,可任意改
session("contpag")=page3
session("contpa")=pa
pages=pa ‘’每页显示数量***************以上一段程序用于实现分页功能
SQL="SELECT * FROM tab order by -dat,-id"
dim rs
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.Open sql,conn,1,1
csi=0
cs1=0
cs100=0
csdat1=0
do while not rs.eof
csi=csi+rs("cs")
if rs("cs")=1 then cs1=cs1+1
if rs("cs")>=100 then cs100+1
if datevalue(rs("dat"))=date then
csdat1=csdat1+1
end if
rs.movenext
loop
ZS=RS.RECORDCOUNT
‘’*****************************************************8以下一段程序用于分页显示
%>
共有条记录,现在是第页 每页显示:[15]条、[20]条、[30]条、[40]条
[刷新]
页码 for i=1 to zs step pages
if page3=cstr(page2) then
%>[]
[]
page2=page2+1
next
sn=pages*(page3-1) ‘’当前记录号=每页显示数*页数-每页显示数
if sn>zs then sn=0
rs.move sn,1
‘’**********************************以上一段用于分页
%>
编号 | 最后访问首页 | 最后访问IP | 首页次数 | 首次访问日期 | "&rs("ID")&" | ""&rs("dat")&" | ""&rs("IP")&" | ""&rs("CS")&" | ""&rs("DAT1")&" | "
合计 | 访问次数为100次以上的有 | 访问次数为1的有: | 总访问次数 | 今天访问量: |
‘’****************************以上是完整的分页显示全部复制下来就可用。没有考虑一条记录也没有的情况。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



DeepSeek cannot convert files directly to PDF. Depending on the file type, you can use different methods: Common documents (Word, Excel, PowerPoint): Use Microsoft Office, LibreOffice and other software to export as PDF. Image: Save as PDF using image viewer or image processing software. Web pages: Use the browser's "Print into PDF" function or the dedicated web page to PDF tool. Uncommon formats: Find the right converter and convert it to PDF. It is crucial to choose the right tools and develop a plan based on the actual situation.

Recently, Huawei announced that it will launch a new smart wearable product equipped with Xuanji sensing system in September, which is expected to be Huawei's latest smart watch. This new product will integrate advanced emotional health monitoring functions. The Xuanji Perception System provides users with a comprehensive health assessment with its six characteristics - accuracy, comprehensiveness, speed, flexibility, openness and scalability. The system uses a super-sensing module and optimizes the multi-channel optical path architecture technology, which greatly improves the monitoring accuracy of basic indicators such as heart rate, blood oxygen and respiration rate. In addition, the Xuanji Sensing System has also expanded the research on emotional states based on heart rate data. It is not limited to physiological indicators, but can also evaluate the user's emotional state and stress level. It supports the monitoring of more than 60 sports health indicators, covering cardiovascular, respiratory, neurological, endocrine,

Solve the problem of third-party interface returning 403 in Node.js environment. When we use Node.js to call third-party interfaces, we sometimes encounter an error of 403 from the interface returning 403...

The impact of sharing of Redis connections in Laravel framework and select methods When using Laravel framework and Redis, developers may encounter a problem: through configuration...

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

How to avoid the third-party interface returning 403 error in the Node environment. When calling the third-party website interface using Node.js, you sometimes encounter the problem of returning 403 error. �...

The advantage of multithreading is that it can improve performance and resource utilization, especially for processing large amounts of data or performing time-consuming operations. It allows multiple tasks to be performed simultaneously, improving efficiency. However, too many threads can lead to performance degradation, so you need to carefully select the number of threads based on the number of CPU cores and task characteristics. In addition, multi-threaded programming involves challenges such as deadlock and race conditions, which need to be solved using synchronization mechanisms, and requires solid knowledge of concurrent programming, weighing the pros and cons and using them with caution.

The main reasons why you cannot log in to MySQL as root are permission problems, configuration file errors, password inconsistent, socket file problems, or firewall interception. The solution includes: check whether the bind-address parameter in the configuration file is configured correctly. Check whether the root user permissions have been modified or deleted and reset. Verify that the password is accurate, including case and special characters. Check socket file permission settings and paths. Check that the firewall blocks connections to the MySQL server.
