Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Simple Php Counter Script, How to make a simple php counter script
Corey
post May 18 2005, 10:41 AM
Post #1


Super Member
*********

Group: Members
Posts: 218
Joined: 13-January 05
Member No.: 3,267



In this tutorial i will explain how to make a simple script writen in PHP...that uses .txt file.

CODE

<?php
// script writen by tema
$a = fopen ("count.txt", "r"); // 1.
$bytes = 4;        
$x = fread($a, $bytes); // 2.
$y=$x + 1;                   // 3.
$fp = fopen ("counter/count.txt", "w+");  // 4.
fwrite ($fp, "$y");     // 5.
fclose ($fp);                // 6.
echo "Posjeta:$y";                // 7.
?>


1. selecting a file which the script is going to use for counting visits.
2. reading from the script
3. adding 1 to the number in the .txt file.
4. opening the .txt file again
5. writeing the new number in the .txt file
6. closeing .txt file
7. writing the number from the .txt file

...you have to include this file somewhere on the start page..,


here are all the script files...for download
http://tema.trap17.com/php/SC-php.rar
http://tema.trap17.com/php/SC-php.zip


if you have some questions about this script post them here,,,...
Go to the top of the page
 
+Quote Post
rvovk
post Aug 7 2005, 12:00 PM
Post #2


Super Member
*********

Group: Members
Posts: 378
Joined: 13-October 04
From: Slovenia
Member No.: 1,731



Very nice script, simple one, but there is one workaround needed. Relative path in line 1 and 4 isn't same. I guess we need to delete "counter/". It worked like a charm, needed 3 minutes to install it.
Go to the top of the page
 
+Quote Post
Adamrosso
post Aug 7 2005, 08:42 PM
Post #3


Advanced Member
*******

Group: Members
Posts: 128
Joined: 6-August 05
Member No.: 10,402



I don't really undertsand what this does? What does it count? Could you explain please?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Mail Form (php)(3)
  2. Php Unique Hit Counter(29)
  3. Php Quiz Script(20)
  4. Php Guessing Script(4)
  5. Email Script/form With Php(35)
  6. E-mail Mailer Script 0.1(4)
  7. Secure The Email Addresses On Your Website!(10)
  8. [php] Simple Newsletter Script(8)
  9. How To Use Trap17 Cgi Formmail(15)
  10. Random Quote Script(6)
  11. Installing Ndstats!(4)
  12. Verifying Email Addresses(9)
  13. Hit Counter(14)
  14. Page Generation Time Script(17)
  15. Script To Build A List Of Links(2)
  1. Php Menu Bulding Script And Site Template(0)
  2. Php Script To Make A Link List(6)
  3. How To: Ip Configuration Script (win Xp)(0)
  4. For ... Next Loops And Script Planning(2)
  5. Image Rotator Script (another One)(0)
  6. How To Create Counter-strike 1.6 Server In Console Mode(5)
  7. Background Image Swap Script(15)
  8. [phpbb] Member Last-visit Report Script(0)
  9. How To Make Your Own Counter Strike Source Dedicated Server!(38)


 



- Lo-Fi Version Time is now: 6th October 2008 - 11:43 PM