...

View Full Version : click counter



ChronicleX.com
06-08-2005, 10:58 AM
i need a small and simple click counter that adds the data to a .txt file

i looked on google and hot scripts but most of them are big scripts. Can someone help me and show me or send a link on how to make a small click counter script???

Thanks

gsoft
06-08-2005, 11:01 AM
http://www.oxyscripts.com/itemdisplay.php?id=1037&code=yes

ChronicleX.com
06-08-2005, 11:02 AM
Thats a hit counter not a click counter???? :confused:

mrruben5
06-08-2005, 11:05 AM
Something like ths? (http://www.phpjunkyard.com/php-click-counter.php)

delinear
06-08-2005, 11:06 AM
Exactly what clicks do you want to measure with the click counter? If you want the flexibility to be able to measure clicks on anything on your site then that is potentially a big project, whereas if you only want to track clicks for downloads on a single page then that would be a lot more straightforward.

Please try to provide as much information about what you want as possible.

ChronicleX.com
06-08-2005, 11:09 AM
just menu links so i can see if users are using the pages...

ChronicleX.com
06-08-2005, 11:12 AM
Something like ths? (http://www.phpjunkyard.com/php-click-counter.php)

i already found that one on google it's the 4th one down in google when you type click counter.

it's to big plus it's got a control panel i don't really need anything like that to fancy..

gsoft
06-08-2005, 11:24 AM
Why not build your own, from what I am hearing nothing suites your needs so making one just sounds like a good idea.

SeeIT Solutions
06-08-2005, 11:25 AM
Why not build your own, from what I am hearing nothing suites your needs so making one just sounds like a good idea.
That is what he asked for.

I'd suggest that making your own hit counter would be better. It is better to use a hit counter for counting our own page loads as people could bookmark your pages, also it is a lot quicker as counting clicks probably requires you to redirect someone to the page they want after it has added the click to the file.

ChronicleX.com
06-08-2005, 11:28 AM
i need a small and simple click counter that adds the data to a .txt file

i looked on google and hot scripts but most of them are big scripts. Can someone help me and show me or send a link on how to make a small click counter script???

Thanks

Quote my slef

THANKS FOR YOUR HELP SO FAR

ChronicleX.com
06-08-2005, 11:31 AM
can someone start me off please?

delinear
06-08-2005, 11:38 AM
Well to implement SeeIT's individual page hit counter idea (which is defnitely better for these purposes than a click counter, after all you only want to see if a user visits a certain page, not count if he clicks back and forth 50 times while he's browsing) essentially all you need to do is register a session or set a cookie the first time the user visits and increment the count for that page in your file. If the session/cookie is already set then don't increment - it's really that simple.

The advantage of cookies is that you can set a specified expiry time, eg a day and don't count any return clicks by that person on that day. The disadvantage of cookies... well, I think they're already well documented. Personally I'd go with the session solution.

ChronicleX.com
06-08-2005, 11:55 AM
so i should go with something like this???




<?php
//
// Make a blank file called count.txt and CHMOD it 777
//
//Lets open the file as read only (r)
$fp = fopen("count.txt","r");
// The next line reads our file into a string,
// in other words sets the contents of count.txt as $count,
// so we can do stuff with it
$count = fread ($fp, filesize ("count.txt"));
// We don't need more data from the file right now, so close it
fclose($fp);
// Now we need to increment the number in the file, using the ++ operator, +1 would work but this is nicer.
$count++;
// Now we've incremented the count, lets write it to the file
// We need to open if for writing (w)
$fp = fopen("count.txt","w");
// Now write the actual data
fwrite($fp, $count);
// And close the file
fclose($fp);
// Lets display the updated count to the users
echo "Hits : $count";
?>

delinear
06-08-2005, 12:38 PM
Well you could use that but bear in mind that it will create a separate file for each page you wanted to track and you would have to collate all the results from those files.

Obviously you can automate this collation so it's not such a big issue but a better solution would be to use that code as a basis but modified to store all the page results in one file and then code a way to retrieve the data and increment the page counts within that one file.

Of course, an even better solution would be to use a database to store the data since it will be much, much simpler to create and manipulate :thumbsup:

ChronicleX.com
06-08-2005, 12:52 PM
Thanks

i will see what i can do with my php skills



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum