An example of statistics that can number visitors, record visits, IP, and time
I made a website, www.zydn.net, of course, like everyone else, I also put a counter on it. I saw the counters constantly flipped every day, and I was very happy, but later I thought, who was watching my website? A new friend or an old friend? I don’t know how many times they have come, but I still want to number them all, so I applied for free statistics, but I was not satisfied with the N changes in a row. Alas, it seems that only by doing it yourself can you have enough food and clothing, and do it as you say it. The level is stinky. I hope the masters will laugh at it and don’t ask for advice.
I take the ACCESS library as an example. In fact, using the SQLSERVER library, you can just change the statements in the link library.
The library structure is as follows
Library file name: CONT.ASP was originally CONT.MDB, but after the build, the extension was changed to ASP to prevent the library from being downloaded.
Table name: tab
Field name data type description
ID automatically number the visitor number
IP text is used to record the IP of the visitor
dat1 date time is used to record the last visitor visitor
dat date time is used to record the time when the visitor first visits
CS number, integer type is used to record the number of visits to the visitor
The program is very simple, there are only two files, dispcont.asp is used to display statistical results, contpage.asp is used to display statistical information,
Let’s first take a look at the statistics of CONTPAGE.ASP, and the code is as follows:
<%
SetConn=Server.CreateObject("ADODB.Connection")
Connstr="DBQ="+server.mappath("cont.asp")+";DefaultDir=;DRIVER={Microsoft AccessDriver(*.mdb)};"
Conn.Openconnstr'*****The above statement is used to connect to the library, and cont.asp is the library file name.
keren=request.cookies("keren")' read cookies, the name of cookies is: "keren", haha. . A Yu's E literature is so bad that he only knows how to use pinyin.
ifkeren=""then'Judge whether cookies are empty. If they are empty, they must be new friends, otherwise they are old friends.
sql="SELECT*FROMtabwhereid=-1"
setrs=server.createobject("ADODB.Recordset")
rs.Opensql,conn,1,3
rs.addnew'If it is a new visitor, add a new record in the library.
rs("cs")=1' Note the number of visits is 1
rs("ip")=request.servervariables("remote_addr")' Note the IP,
rs("dat")=now'Tell me the current date and time,
rs("dat1")=date'Tell the current date, and the date to be used for the first visit in the future.
response.cookies("keren")=rs("id")'Write a cookie and the content is the same as the ID.