Search Tools Links Login

Get IP ADDRESS


This is usefull program to track people's IP.
Visit Count for each visiting IP address. Assume that the table IPAddresses(IPAddress, Count) exists in the DSN yourDSN.

Original Author: vsim

Code



Visit Counts per ip addresses


<%
'  Get Remote IP Address.
IPAddress = Request.ServerVariables("Remote_Addr")
'  Open database connection.
Set conn = Server.CreateObject("adodb.connection")
conn.open "yourDsn"
'  Check to see the IP address exits.
'  Inefficient: to be modified.
sql = "select * from IPAddresses" & _
   " where IPAddress = '" & IPAddress & "'"
set result = conn.execute(sql)12:09 AM 8/8/01
if (not result.eof) then ' one result
  Count = Clng(result.fields.item("Count")) + 1
  sql = "update IPAddresses set Count = " & Count & _
     " where IPAddress = '" & IPAddress & "'"
else
  Count = 1
  sql = "insert into IPAddresses values('" & _
     IPAddress & "', " & Count & ")"
end if
conn.execute(sql)
conn.close
'  Print result.
Response.write("IP Address " & IPAddress & " has visited " & _
"this page for " & count & " times.")
%>


About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 140 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.