anyone can give me code for a php hit counter for my website...that will count every user's click...plzz give with database & code...

We aren't here to programm for you, we are here to help you program. Do you have any knowledge of PHP?

no actually I can't create a counter that will count every user...my counter count on every reload...thats why...

Post your counter and I will take a look at it. ;)

if you need a simple one, why don't you search on google?

ill tell you the logic/alogrithm of what you can do.

use cookies or sessions but using cookies is better then you can record unique users. u create a cookie, and that cookie gets saved in ur computer's hard drive. delete the cookie after every 24 hours. you can set this when you create the cookie.

when u come back again check if the cookie exists or not. if it does then your visit will not be recorded as youhave already visited that day. if the cookie does not exist then your visit will be logged as it will be your first visit that day.

now convert this logic/algorithm into code.

Member Avatar for diafol

Google 'php page counter' - script bunny heaven. Hotscripts and Sourceforge have loads of amazing free stuff, but some of them tend to be a little over-the-top for what you need.

You could cookify it like suggested above or your best bet would be a total MySQL solution. However, you'll need to "bone up" a bit on your php for this.

no actually I can't create a counter that will count every user...my counter count on every reload...thats why...

When talking about website statistics, usually a "hit" refers to the access of any resource on the server such as html files, images, audio, video etc.

that will count every user's click...plzz give with database & code...

Do you want to count unique visitors, or the clicks of each visitor, or both?

If you're counting clicks, then you most likely want the number of hits on php or html files. They are the same as clicks.

If you want unique visitors, then you need cookies like mentioned by mustafaneguib. There are already existing solutions:
eg: http://piwik.org/
Or services that provide visitor analysis such as google analytics.

A lot of this information is already available in the server logs, if you have a access logs enabled.

There are many existing parsers for server logs that display the log data visually.

eg:

http://www.webalizer.org/
http://awstats.sourceforge.net/

Usually, these are already existing on PHP enabled servers and is already built into CPanel .

Website statistics generated from log analysis do not contain visitor counts, or visit counts. This is because a visitor can only be identified well by a cookie (or other client side storage). IPs cannot be used since some users have dynamic IPs and some groups of users can use a single IP.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.