Counter of sorts

Joined
Feb 25, 2003
Messages
5,279
Reaction score
138
Points
63
Location
Tropical Island, Jealous?
Your Mac's Specs
MacPro 3.0Ghz 16GB RAM, 4x256 Vid, 30''cinema display
:) im not exactly an expert html coder, I only bothered learning enough to build a quality site.

I am now wondering about a counter, I hate seeing counters on pages... but it may be the only way I can get an accurate # of visits to mysite.

Anyone have a better way? Ide hate to clutter my site with a visible counter.
 
Joined
Jan 15, 2003
Messages
4
Reaction score
16
Points
3
Location
Whangarei, New Zealand
Your Mac's Specs
Pwnt
You can make a relatively easy invisible one with php. Do you know any php? I can't remember the code off the top of my head but I'll try find a tutorial for you.
 
OP
G
Joined
Feb 25, 2003
Messages
5,279
Reaction score
138
Points
63
Location
Tropical Island, Jealous?
Your Mac's Specs
MacPro 3.0Ghz 16GB RAM, 4x256 Vid, 30''cinema display
ok thnx man. invisible would be best, cus I can't stand clutter :)
 
Joined
Jan 15, 2003
Messages
4
Reaction score
16
Points
3
Location
Whangarei, New Zealand
Your Mac's Specs
Pwnt
here you go: PHP hit counter

Just the basic outline so you can understand what the code means;
  • Anything with a $ in front of it is a variable, it is either being assigned or being displayed
  • Page 2 is optional, leave it out if you want an invisible counter, just make sure you add the very first line of it to the page you want counted (the <?php include... ?> one) at the top of your document.
  • The stuff between the <? and ?> is the php code, and can be put inside another document or linked to as a separate one.
  • To use php scripts in a html document (not as a standalone one), the eaisest way is to rename your file from .html to .php

What the script does: The file countFunction.php is a file that is separate from everything else and linked to from your index.php page (make sure your page is index.php not index.html). When the browser loads the page it also loads and executes that file. The php code asks the browser if the user has been counted already (in the current session) and if not, writes to the file counter.txt the new number of visitors.

Something I find really useful but is completely unrelated: If you have a site where the same thing appears on each page but changes often (i.e. a news bar on the side or something you want to spotlight), put the corresponding code with all the html tags into a file, yourfilenamehere.txt. Take it out of the original page, and put this line of code into where you want the information displayed: <?php include "yourfilenamehere.txt"; ?>. Change index.html or whatever page it is to index.php and you're away. If you change the text file it will change the html file. So you can add this piece of code to any page you want and it will always display the same.

[edit]Oops, for the function to be called that does all the work, you will need to have the line <?php Counter(); ?> in there somewhere... but this will display the number of hits. Edit the last line "echo $finalcount" out of countFunction.php.
 
Joined
Oct 27, 2002
Messages
1,345
Reaction score
0
Points
36
Location
Vermont
Your Mac's Specs
17" iMac G4 800MHz 1GB RAM
Who is your host? You should be able to access web server statisctics.....
 
OP
G
Joined
Feb 25, 2003
Messages
5,279
Reaction score
138
Points
63
Location
Tropical Island, Jealous?
Your Mac's Specs
MacPro 3.0Ghz 16GB RAM, 4x256 Vid, 30''cinema display
Thnx muso big help (Ill end up messin up some lil thing so I know ill be back :D)

Emrys, my host is my school... they weren't to clear on what we could have on our sites... ie software company site.. but I don't wana pester them in the case Im not suppose to have that :D that and im pretty sure the tech support here knows less then me (AND IVE NEVER SEEN THE SERVER).
 
OP
G
Joined
Feb 25, 2003
Messages
5,279
Reaction score
138
Points
63
Location
Tropical Island, Jealous?
Your Mac's Specs
MacPro 3.0Ghz 16GB RAM, 4x256 Vid, 30''cinema display
Yeah, Im messing something up. Ive got class in 10 so perhaps im just in a rush.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top