View Full Version : php counter
nobody
May 13th, 2003, 07:26 PM
I did a search, please don't beat me too hard if this has been asked a million times.
How could I make a hit counter in PHP? Just a simple text one.
I'm sure it would be an easy task and I have a semi-solid idea how to do it, I just don't really know how to code it.
I was thinking you would set up a variable that would just be increased each time someone visited a page and that number would be drawn from the text file and displayed. I'm not worried about IP stuffs or anything.
Any help would be thuper
ahmed
May 13th, 2003, 07:27 PM
there ya go ;)
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=18524&highlight=%2Acounter%2A
Jubba
May 13th, 2003, 07:28 PM
http://www.daydreamgraphics.com/tutorials/list.php?cat_id=2
theres a tutorial for a counter on that page...
Jubba
May 13th, 2003, 07:28 PM
hmmmm grrrrrr
nobody
May 13th, 2003, 07:33 PM
Originally posted by ahmed
<<!--- --->?php
$handle = fopen("counter.txt", "r");
$contents = fgets($handle, 4096);
$temp = sprintf("%d", $contents);
$temp++;
fclose($handle);
$handle = fopen("counter.txt", "w");
fputs($handle, "$temp");
fclose($handle);
echo ($temp);
?<!--- --->>
this should do it :)
ok i found that, and im assuming that is what you would put in the html page that would load the variable, but what would be in the txt file?
Jubba
May 13th, 2003, 07:36 PM
that is a php file.
save a text file with the extention .php
so that would be
"counter.php"
then make a text file called "counter.txt"
and then in Flash you would loadVariables from counter.php
nobody
May 13th, 2003, 07:38 PM
I'm not doin it in flash:P
I just tried the link you said jubba, and I'm uploading right now to see if it worked
nobody
May 13th, 2003, 07:39 PM
http://xxviii.net/
do you see that big 'ol ugly thingy too?
Jubba
May 13th, 2003, 07:39 PM
oh ok, you don't want flash, then you would use the same code. that prints out the number you want :) check out that tutorial, it should be of use... if you don't know php then Ahmed's explanation might not help too much...
nobody
May 13th, 2003, 07:42 PM
haha oops.. i didnt have it CHMODed
sorry for the dumb post
thanks a ton jubba and ahmed
really helpful as always
just a quick question, how can i edit the color and stuff it displays in?
Jubba
May 13th, 2003, 08:07 PM
print out font tags before and after you print out the varialbe...
nobody
May 13th, 2003, 08:52 PM
thanks jubba... got it all worked out now.. i even get how it works
thanks for puttin up with me:beam:
ahmed
May 13th, 2003, 09:01 PM
Originally posted by Jubba
hmmmm grrrrrr sorry jubbs :P ;)
Jubba
May 13th, 2003, 09:48 PM
always beating me! :P
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.