Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I code a counter?

Status
Not open for further replies.

LadyRose

Programmer
May 17, 2000
16
US
I need to develop a counter.  The purpose is to record hits.  I would like to maintain a table recording the IP's and add to the counter only if it is a new hit and not a repeat hit.  Any clues?
 
Rose,<br>&nbsp;&nbsp;&nbsp;Assuming you want to track each visitor to your site (as opposed to tracking each page) in session_onstart, read the last value from your database, increment it, and write the new value to the database.<br>&nbsp;&nbsp;&nbsp;Tracking users by IP address isn't a good idea, unless you're on an intranet.&nbsp;&nbsp;When people access your site from a site that uses a proxy server,&nbsp;&nbsp;you get the address of the proxy server, not the user's system.&nbsp;&nbsp;That means that everybody that uses that proxy server will show up with the same IP address. <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
Thank-you Nick.&nbsp;&nbsp;I had thought of this, but didn't know where to code it.&nbsp;&nbsp;Would using a database or a file to record the count be a better idea.<br>I guess what I am asking is: Would a database be a slower access time?<br><br>Thanks.
 
It's hard to determine which method would be faster,&nbsp;&nbsp;since it depends on how much data you're collecting, how many records there are, and how efficient the code is that you're using to access the file.&nbsp;&nbsp;In my opinion,&nbsp;&nbsp;unless you only have a small amount of data,&nbsp;&nbsp;I'd use a database. <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top