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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

How to configure Zend in Apache? The steps to configure Zend Framework in an Apache Web Server are as follows: Install Zend Framework and extract it into the Web Server directory. Create a .htaccess file. Create the Zend application directory and add the index.php file. Configure the Zend application (application.ini). Restart the Apache Web server.

This article will explain how to improve website performance by analyzing Apache logs under the Debian system. 1. Log Analysis Basics Apache log records the detailed information of all HTTP requests, including IP address, timestamp, request URL, HTTP method and response code. In Debian systems, these logs are usually located in the /var/log/apache2/access.log and /var/log/apache2/error.log directories. Understanding the log structure is the first step in effective analysis. 2. Log analysis tool You can use a variety of tools to analyze Apache logs: Command line tools: grep, awk, sed and other command line tools.

Apache server is a powerful web server software that acts as a bridge between browsers and website servers. 1. It handles HTTP requests and returns web page content based on requests; 2. Modular design allows extended functions, such as support for SSL encryption and dynamic web pages; 3. Configuration files (such as virtual host configurations) need to be carefully set to avoid security vulnerabilities, and optimize performance parameters, such as thread count and timeout time, in order to build high-performance and secure web applications.

This article describes how to effectively monitor the SSL performance of Nginx servers on Debian systems. We will use NginxExporter to export Nginx status data to Prometheus and then visually display it through Grafana. Step 1: Configuring Nginx First, we need to enable the stub_status module in the Nginx configuration file to obtain the status information of Nginx. Add the following snippet in your Nginx configuration file (usually located in /etc/nginx/nginx.conf or its include file): location/nginx_status{stub_status

Nginx performance monitoring and troubleshooting are mainly carried out through the following steps: 1. Use nginx-V to view version information, and enable the stub_status module to monitor the number of active connections, requests and cache hit rate; 2. Use top command to monitor system resource occupation, iostat and vmstat monitor disk I/O and memory usage respectively; 3. Use tcpdump to capture packets to analyze network traffic and troubleshoot network connection problems; 4. Properly configure the number of worker processes to avoid insufficient concurrent processing capabilities or excessive process context switching overhead; 5. Correctly configure Nginx cache to avoid improper cache size settings; 6. By analyzing Nginx logs, such as using awk and grep commands or ELK

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.
