A PHP web counter?

This is a discussion on "A PHP web counter?" within the PHP Forum section. This forum, and the thread "A PHP web counter? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 14th, 2004, 18:10
New Member
Join Date: Feb 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to k3nshin
A PHP web counter?

I know my host allows PHP and I have my page built in html. can someone please tell me a code where I can add the php tags into my HTML and have a web counter? that would be mega nice of you!

-mark

  #2 (permalink)  
Old Feb 14th, 2004, 21:59
Up'n'Coming Member
Join Date: Oct 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jamslam
In order to put PHP into your HTML files, you need to rename all your .html files to .php extensions.

You can then put "<?php php_code ?>" anywhere in that PHP file.

There is only one difference between a .html file and a .php file. And that is that you can use PHP in the .php file. Otherwise, they work exactly the same in every way.

If you're looking for a PHP web counter to put on your site, it would require some sort of database. However, I'd probably advise finding a site that you can use a web counter off of. If you have cpanel they should have a built in feature that allows you to create your own web counter
  #3 (permalink)  
Old Feb 14th, 2004, 22:09
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Hi Mark,

You need somewhere to store the count, either a database or a text file. Seeing as it's pretty stupid to use a database for just one piece of information, a text file is much better!

First create an empty file called hitcounter.txt.

Then make another file called hitcounter.php and put in the following code:

Code: Select all
<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
echo $hits[0];
?>
That will add 1 each time the file is hit.

You can use:
include ("hitcounter.php");
to include the file in any other, so that when they hit that page it is counted too.

To make the counter silent (so it doesn't display a number) remove the line "echo $hits[0];"
  #4 (permalink)  
Old Feb 14th, 2004, 23:08
Up'n'Coming Member
Join Date: Oct 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jamslam
Ah sirkent, I've forgotten about flat-file storage!

Just to add, make sure the "hitcounter.txt" has read and write privleges... So you'd need to chmod it to "0755" (is that correct?). You should be able to "chmod" a file via your FTP client.
  #5 (permalink)  
Old Feb 15th, 2004, 08:54
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, CHMOD is important, sorry. 755 should do the trick.
  #6 (permalink)  
Old Feb 17th, 2004, 00:20
New Member
Join Date: Feb 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to k3nshin
Wow... !! you guys have helped me soooo much! Thank You! if you would like to see my new sleek top of the line php web page the location is at http://www.hostultra.com/~k3nshin/ im so excited!!

- Mark
  #7 (permalink)  
Old Feb 17th, 2004, 00:23
New Member
Join Date: Feb 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to k3nshin
oh lol forgot to tell you... DONT LAUGH!! hehe im still learning all this php and other stuff! so Thanx again and ill cya around! :razz:
  #8 (permalink)  
Old Feb 17th, 2004, 08:41
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
It looks fine to me! The only thing worth mentioning is that the green bar on the right stops before the bottom. Looks good, keep it up!
  #9 (permalink)  
Old Feb 17th, 2004, 08:55
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
nice site, whats "Rurouni Kenshin" then ??:
  #10 (permalink)  
Old Feb 17th, 2004, 12:03
New Member
Join Date: Feb 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to k3nshin
I LOVE THIS FORUM! hehe but anyways Rurouni Kenshin is an Anime started by Nobuhiro Watsuki ummm that wont help heres a link to a better Rurouni Kenshin fansite. http://www.geocities.com/kkfan007
  #11 (permalink)  
Old Feb 18th, 2004, 07:55
Up'n'Coming Member
Join Date: Oct 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jamslam
I'm sorry to rain on your parade k3nshin, but that's a freeweb template. Did you know that it is illegal to take someone's template, and try to pass it off as your own?

You may have modified it, but you're still using the same basic layout, colors, and images as that template.
  #12 (permalink)  
Old Feb 18th, 2004, 10:47
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
((oh god not more templates))
  #13 (permalink)  
Old Feb 18th, 2004, 17:29
Up'n'Coming Member
Join Date: Oct 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jamslam
Yea I know right... but that template is built into freewebs. I see people using it all the time.
  #14 (permalink)  
Old Feb 18th, 2004, 21:24
New Member
Join Date: Feb 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to k3nshin
I'm sorry I didnt spend the time writing all that pointless HTML I alreaddy know... besides tell me please where on my site it says its mine? I never said it was mine but merely used it.

Liking the forum level: 7/10
  #15 (permalink)  
Old Feb 18th, 2004, 22:10
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Lol, you like us less because we mention the truth?
  #16 (permalink)  
Old Feb 18th, 2004, 23:46
New Member
Join Date: Feb 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to k3nshin
No sirkent I dont like the forum less rather the person that said that... sorry if there was any confusion lets just call that a brain malfunction like they called janet jacksons shirt getting ripped a wardrobe malfunction lol :razz:
  #17 (permalink)  
Old Feb 19th, 2004, 06:22
Up'n'Coming Member
Join Date: Oct 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to jamslam
<blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote">Originally posted by k3nshin

I'm sorry I didnt spend the time writing all that pointless HTML I alreaddy know... besides tell me please where on my site it says its mine? I never said it was mine but merely used it.

Liking the forum level: 7/10
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

Really? Well when you removed that little blurb at the bottom of the template that said "made and built by freewebs", it thus leaves anyone that see's your site to insinuate that you built that template, what else would we think? Pointless HTML you already know? Hmmmm... I guess the language used in every single web site is pointless.

Liking the forum level: 15/10
  #18 (permalink)  
Old Feb 19th, 2004, 07:44
Highly Reputable Member
Join Date: Aug 2003
Location: Australia
Posts: 662
Thanks: 0
Thanked 0 Times in 0 Posts
Also it has your copyright info at the bottom.. I doubt you own any copyrights, don't put a symbol unless you can back it up.. Copyrights aren't free things you get cause you use a symbol. People pay dearly for them.
  #19 (permalink)  
Old Feb 19th, 2004, 08:04
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Put a small disclaimer at the bottom of your page, something like: Site layout or adapted from an idea <site link>.

People won't think any less of you, if anything it will do you credit. People go to your site because of content, not design.

Whats with the rating, 7/10? I think you did a typo, shouldn't it have been 10/10.

u2o
  #20 (permalink)  
Old Feb 19th, 2004, 22:35
New Member
Join Date: Feb 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to k3nshin
wow im readdy to ask someone to close this post not only too many pointless things said but also im done with it...
Closed Thread

Tags
php, web, counter

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Age Counter acrikey JavaScript Forum 4 Jun 2nd, 2008 12:37
Counter confused Website Planning 6 May 21st, 2007 03:27
Email Counter usfgeoff PHP Forum 3 Jan 21st, 2007 23:09
hit counter? skyfire400 Web Page Design 6 Mar 7th, 2006 14:00
print "$counter times 2 is ".($counter*2)."<br>" gwx03 PHP Forum 6 Dec 10th, 2003 10:50


All times are GMT. The time now is 07:02.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43