| | I personally use and would highly recommend Statcounter, a free counter tracking service. It's so much more powerful than other free counters with its advanced visitor reporting and more. |
|
|
As I said in the other Forum I have also used statcounter and suggest you at least try it. It is ad free and u have the option to make it invisible or give it a range of colours. You can also with the one acount use it for multiple sitesand pages.
ok I use the Mysql database to store the counter results. coz i have a database maintained already for the site...
the code is simple just fetch the row with the counter... and use echo display on the page... why bother about the security... The data base is secured...
@Darren : seems to be interesting from what you say. I will give statcounter a try, and will compare to astahost's one. The one from astahost is also really impressive, I like it. Besides that I forgot my statcounter's password, and I am still waiting for the mail with it.
Yordan OK, Darren, your are right, statcounter is really great. Their counters are not so nice as astahost ones, and the menus to step inside are not really easy to understand, and I experienced several disconnections in the middle of the process of creationg your counter. But if you want something really simple, without any ads, it's a simple line to be included inside your html source. And it works anywhere, including on your own PC for testing purposes, which is not the case for the astahost counter. So, if you want something easy to implement, very nice, with a comfortable menu-diriven settings, use astahost's cpanel one. If you want something simple, which works on any site including your PC, use statcounter.
Not too bad, it's a pretty simple counter, but it get's the job done.
I've been trying to figure out this one though, how do we make a download counter, that one is a bit harder isn't it? I suppose we'd make a page that would open the file's URL in a redirect, but also add to the counter and direct them to that instead of the counter?
I like your script, it is clean and simple. It's a great use for light purposes. I use this to improve my website.
Although I like to use more heavy stats that give you greater detail in visitors. You just have to: CODE CREATE TABLE website_counter (visits int(10)) And put this code in the top of each page that you want to be counted: CODE $conn = mysql_connect("YOUR HOST","YOUR USER","YOUR PASSWORD") or die('MySQL said: ' . mysql_error()); $db = mysql_select_db($db); $sql = mysql_query("SELECT * FROM website_counter") or die('MySQL said: ' . mysql_error()); while($visits = mysql_fetch_array($sql)) { $visits = $dados["visits"]; $visits_new = $visits + 1; } $query = "UPDATE TABLE website_counter SET visits = $visits_new"; mysql_query($query, $conn) or die(mysql_error()); And where you want to show the number os visits: CODE echo ("Visits: $visits_new"); OBS.: I didn't test it. If you got any errors, post here.
Hmm, I think the counter (at the beginning of this thread) can't be deloyed on busy site. Because if many pages read and write that file at once, there can be a error when accessing alle.txt
@Alexandre : your program has a great advantage, you are independent from any provider, so you can use it on a server other than astahost, or even on a server on a private network.
QUOTE OBS.: I didn't test it. yes, it has to be tested first. For instance, I am curious to see where $dados is defined.
For a simple php counter there's no need to use databases, flatfiles will do fine, the example by websaint is suffice as long as
CODE <p>Number of guests visiting my site: <? include('alle.txt'); ?>.</p> Is stored on the server and is not changeable or dependable on userinput. Anyway, I was thinking that using an OOP approach here might be an overkill. What if you take the following PHP file vc.php CODE <?php $countfile = file("alle.txt"); $count = $countfile[0]; $count= $count + 1; $fp = fopen("alle.txt","w"); $fw = fwrite($fp,$count); fclose($fp); echo $count; } ?> Basically you know that whenever vc.php is called there is a new page visit so which means that you need the variable $count back. So all you need to do now in your other php files is to have them include("vc.php") in the code. eg index.php CODE <?php echo("hi"); include("vc.php"); ?> This would be failsafe for any crosssitescripting attempts since there's no userinput expected. Also, even if the name of vc.php is known so people can call it directly, it doesn't matter since they could only +1 to your counter, which is also possible if they reload your page 20+ times. Also, people still need to know the name of the counter script, which is quite difficult to guess if they don't see it stated somewhere. Alternatively, you could also add an ip banning system to this script to check if a user has accessed this site before. Which is not really necessary if you want to know how much your page has been loaded. About the busy website thing, it'd take quite a lot of requests per second to be faster than the opening and writing of one byte in a single file for it to have a deadlock. Also, If one has a busy site that can accomplish such thing, it'd be wiser to use a database approach since you can generate more statistics than just the amount of page visits (which is only interesting with a lot of visitors). Ps. Anything flash is bad
Recent Queries:-
Keywords : make, simple, counter, php
With MySQL (2) websaint recently posted a PHP hit counter using a flat-file to store information. This is a guide Looking for make, simple, counter, php
|
|
![]() Make Your Own Very Simple Counter Using PHP! |