Important alert: (current site time 7/16/2013 6:43:43 AM EDT)
 

VB icon

Hit Counter for a web site

Email
Submitted on: 7/12/2002 12:19:53 PM
By: Mian Omar  
Level: Intermediate
User Rating: By 1 Users
Compatibility: Cold Fusion 4.5
Views: 15001
author picture
(About the author)
 
     My Code create a Hit Counter For a Web Site,You can check that how many user visit your site
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Hit Counter for a web site
// Description:My Code create a Hit Counter For a Web Site,You can check that how many user visit your site
// By: Mian Omar
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=56&lngWId=9//for details.//**************************************

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title>Untitled</title>
</head>
<body>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title>Counter</title>
</head>
<body>
<!--- 
First create a table Name Countertable
	There are two fields which you created 
		 i) Userid		Autonumber
		ii) Totaluser 	Number
* i use Access database 
 --->
<!--- 
	First we Check that a Cookie is exists or not
	if cookie exists then totaluser is increase by 1
	otherwise if cookie does not exists then it create
	and for the first time its value is one
 --->
	<cfif not isdefined("cookie.countuser")>
		<cfcookie name="countuser" value="true">
<!--- Check if any entery is exists or not if exists 
	 then recordcount greate then 0 else equal to 1 
--->
		<cfquery name="checkuser" datasource="datasourcename">
			Select * from Countertable
		</cfquery> 
<!--- 
	if first query record count greate then 0 we update pervious entry by 1 increatment
 --->
			<cfif #checkuser.recordcount# gt 0>
				<cfquery name="updateuser" datasource="datasourcename">
					Update Countertable set totaluser=#checkuser.totaluser#+1
				</cfquery>		
<!--- 
	If first query.recordcount equal to 0 then it mean no user visit our site
	so first time we insert 1 in totaluser field
 --->
	<cfelse>
				<cfquery name="insertuser" datasource="datasourcename">
					Insert into Countertable(totaluser) Values(1)
				</cfquery>				
			</cfif>
			
	<cfelse>
				<!--- Do according to your choice --->	
	</cfif>
	<!---
	 A again query for retriving data from table to check that how many user viste our site
	--->
	<cfquery name="total" datasource="datasourcename">
		Select * from Countertable
	</cfquery>
	
	<cfoutput>There are #total.totaluser# User Viste our Site </cfoutput>
</body>
</html>
</body>
</html>


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

10/6/2005 4:52:16 AMWenny

Cool Code!
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.