一个能对访问者进行编号、记录访问次数、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的有: | 总访问次数 | 今天访问量: |
‘’****************************以上是完整的分页显示全部复制下来就可用。没有考虑一条记录也没有的情况。

MySQLdiffersfromotherSQLdialectsinsyntaxforLIMIT,auto-increment,stringcomparison,subqueries,andperformanceanalysis.1)MySQLusesLIMIT,whileSQLServerusesTOPandOracleusesROWNUM.2)MySQL'sAUTO_INCREMENTcontrastswithPostgreSQL'sSERIALandOracle'ssequenceandt

MySQL partitioning improves performance and simplifies maintenance. 1) Divide large tables into small pieces by specific criteria (such as date ranges), 2) physically divide data into independent files, 3) MySQL can focus on related partitions when querying, 4) Query optimizer can skip unrelated partitions, 5) Choosing the right partition strategy and maintaining it regularly is key.

How to grant and revoke permissions in MySQL? 1. Use the GRANT statement to grant permissions, such as GRANTALLPRIVILEGESONdatabase_name.TO'username'@'host'; 2. Use the REVOKE statement to revoke permissions, such as REVOKEALLPRIVILEGESONdatabase_name.FROM'username'@'host' to ensure timely communication of permission changes.

InnoDB is suitable for applications that require transaction support and high concurrency, while MyISAM is suitable for applications that require more reads and less writes. 1.InnoDB supports transaction and bank-level locks, suitable for e-commerce and banking systems. 2.MyISAM provides fast read and indexing, suitable for blogging and content management systems.

There are four main JOIN types in MySQL: INNERJOIN, LEFTJOIN, RIGHTJOIN and FULLOUTERJOIN. 1.INNERJOIN returns all rows in the two tables that meet the JOIN conditions. 2.LEFTJOIN returns all rows in the left table, even if there are no matching rows in the right table. 3. RIGHTJOIN is contrary to LEFTJOIN and returns all rows in the right table. 4.FULLOUTERJOIN returns all rows in the two tables that meet or do not meet JOIN conditions.

MySQLoffersvariousstorageengines,eachsuitedfordifferentusecases:1)InnoDBisidealforapplicationsneedingACIDcomplianceandhighconcurrency,supportingtransactionsandforeignkeys.2)MyISAMisbestforread-heavyworkloads,lackingtransactionsupport.3)Memoryengineis

Common security vulnerabilities in MySQL include SQL injection, weak passwords, improper permission configuration, and unupdated software. 1. SQL injection can be prevented by using preprocessing statements. 2. Weak passwords can be avoided by forcibly using strong password strategies. 3. Improper permission configuration can be resolved through regular review and adjustment of user permissions. 4. Unupdated software can be patched by regularly checking and updating the MySQL version.

Identifying slow queries in MySQL can be achieved by enabling slow query logs and setting thresholds. 1. Enable slow query logs and set thresholds. 2. View and analyze slow query log files, and use tools such as mysqldumpslow or pt-query-digest for in-depth analysis. 3. Optimizing slow queries can be achieved through index optimization, query rewriting and avoiding the use of SELECT*.


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

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
