LiveZilla Live Help
 


Go Back   Chime Host - Web Hosting Forum > World Wide Web > Programming / Scripting / Coding Forum > PHP
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

PHP The most widely used server-side programming language for web applications.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-06-2007, 06:53 PM
Member
 
Join Date: Aug 2006
Ryan56 is on a distinguished road
Default How To Make A Hit Counter

This simple script creates an image that can be used on any page to display a hit counter. A session variable is used to ensure that the counter only advances once per browser session. In your html, put an <img> tag for the image, such as this one
PHP Code:
<img src="counter.php" alt="" style"border-style:inset; border-width: 3; left: 20; top: 20; position: absolute;"
2) Now make a new file name "counter.php" without the " " in the directory where your site is.

3)edit the counter.php file

4) put the following code in it

PHP Code:
<?php
session_start
();
if (!
session_is_registered('hit_cnt_entry')) {
session_register('hit_cnt_entry');
$hit_cnt_entry "0";
} else {
$hit_cnt_entry "1";
}

$filename 'counter.dat';

if (
is_writable($filename)) {

$handle fopen($filename,"r");
$count fread($handlefilesize ($filename));
fclose($handle);

if (
$hit_cnt_entry == "0") {
$handle fopen($filename,"w");
$count $count 1;
fwrite($handle,"$count");
fclose($handle);
}

$width = (strlen($count) * 8) + 8;

$im = @imagecreate ($width18);
$background_color imagecolorallocate ($im255255255);
$text_color imagecolorallocate ($im000);
imagestring ($im442$count$text_color);
imagepng ($im);
imagedestroy($im);

}
?>
the counter value in stored in a different file so

5) open notepad and put a number in it for example "100" this will be the number of hit that will be shown on the counter.

6) name the file counter.dat and upload it to the name directory where you created the counter.php file

and that's it your finished

You can cheat at any time just by changing the number in the counter.dat with notepad. i have also attached the counter.php and the counter.dat file ina zip


here is my finished file http://www.gmgraphics.profusehost.ne...ter/index.html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-05-2007, 05:26 AM
Member
 
Join Date: Nov 2007
spoweb is on a distinguished road
Default

I made it in the file manager, but I placed in the "body" tags. There's an x where the image should be. What can I do to make the image appear? Should I take out ALL of the HTML code that was in there to begin with and leave it as a pure PHP file?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-08-2008, 09:01 PM
Junior Member
 
Join Date: Jun 2008
bokepwap is on a distinguished road
Default

this is simple php counter visitor,
this code make a counter per days
PHP Code:
    <?php
    $fn 
"counter.txt";
    
$fp fopen($fn"a+");
    
$fs filesize($fn);
    
$tdy date("d/m/y");
    if (
$fs==0)
    {
    
$co 1;
    
fwrite($fp$tdy."-".$co);
    }else{
    
$info fread($fp$fs);
    
$cdata explode("-"$info);
    
ftruncate($fp0);
    if(
$tdy==$cdata[0])
    {
    
$co $cdata[1]+1;
    
fwrite($fp$tdy."-".$co);
    }else{
    
$co 1;
    
fwrite($fp$tdy."-".$co);
    }
    }
    
fclose($fp);
    
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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
How to submit an html form to a Table? rskha HTML/CSS/DHTML 1 02-05-2010 09:32 AM
Is there any way to do CGI at home on my computer? kelsey Programming / Scripting / Coding Forum 1 01-20-2010 05:31 AM
If else nesting in Javascript. Help what am I doing wrong? kitten_nik Javascript 0 01-16-2010 07:24 PM
php and mysql problem? saurabh PHP 0 12-30-2009 07:23 PM
A sports section bizzard Suggestions 2 12-10-2008 10:43 AM


All times are GMT +1. The time now is 12:52 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ChimeHost, a Profuse Solutions LLC company