Tutorials: Simple Hit Counter

Discussion in 'PHP' started by mizuki, Jan 20, 2007.

  1. #1
    Step 1: creat new file with name counterlog.txt.

    Step 2: Creat new file counter.php with information:

    <?php   
    
    $viewss = file("counterlog.txt");   
    
    $views = $viewss[0]; $views++;   
    
    $fp = fopen("counterlog.txt", "w");   
    
    fwrite($fp, $views);   
    
    fclose($fp);   
    
    ?> 
    PHP:
    Step 3: upload 2 file on your host and CHMOD on counterlog.txt 777.

    Step 4: And you can includes this code to anyone(you need counter active).

    <?php   
    
    include ("counter.php");   
    
    ?> 
    PHP:
    Displays your counter by thi code :

    <?php   
    
    print $views;   
    
    ?> 
    PHP:
    all information from T4VN.NET

    http://www.t4vn.net/tutorials/showtutorials/Simple-Hit-Counter.html
     
    mizuki, Jan 20, 2007 IP
  2. vinodkv

    vinodkv Peon

    Messages:
    183
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    great tutorial if any one know the php, otherwise they must have some doubt so please elaborate....
     
    vinodkv, Jan 20, 2007 IP
  3. smiNICOLETTE

    smiNICOLETTE Peon

    Messages:
    45
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks. simple, but effective. appreciate sharing.
     
    smiNICOLETTE, Jan 20, 2007 IP