TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 01-17-2010, 03:01 PM   #1 (permalink)
The Wanderer
 
Join Date: Jan 2010
Posts: 10
Thanks: 4
Monferno is on a distinguished road
Default Hit Counter Help

Hello

I have recently decided I was going to create a Hit Counter in PHP for my site when it goes up. Sadly when I run it it decided that it will not work for me.

The main file with all of the PHP coe in is called class.php. The contents of the file are:
PHP Code:
    function showHitCounter($file) {
    
        
$counterFile $file;
        
        print 
'<div id="hit-counter">';
            include(
$counterFile);
        print 
'</div>';
    
    }
    
    function 
hit($file) {
    
        
$T 'T';
        
        if (isset(
$_COOKIE['hit-today']) {
        
            print 
'<!-- This user has already had their hit counted today -->';
        
        }
        
        else {
        
            
$fo fopen($file'r+');
            
$contents fread($fo10)+1;
            
            
fwrite($fo$contents);
            
            
fclose($fo);
            
            
setcookie('hit-today''T'time()+86400);
        
        }
    
    } 
Basicly, in the index file, I call the file class.php and then run the hit function.

I have a live example http://seaglass-jewellery.com/example/HitCounter/ (here)

Can anyone help me?
Monferno is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB 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
Using a simple counter harryhood General 6 04-13-2005 01:38 PM


All times are GMT. The time now is 10:17 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design