Like this code?
Show the author your appreciation.
A simple and fast counter for beginners and low bandwidth sites
<?php
$counterFile = "/home/httpd/html/counter/counter.text";
function displayCounter($counterFile) {
global $counted
$fp = fopen($counterFile,rw);
$num = fgets($fp,5);
if (!$counted) {
$num += 1;
unlink("$counterFile");
exec("echo $num > $counterFile");
}
print "$num";
}
if (!file_exists($counterFile)) {
exec("echo 1 > $counterFile");
}
displayCounter($counterFile);
?>
/* Add the following to the very top of the page you want to count */
<?php if (!$counted) { setcookie("counted",1,time()+600); } ?>
Simple Cookie example Categories : PHP , Beginner Guides , Cookies A flat file counter Categories : PHP , Cookies , Filesystem , Beginner Guides A very simple PHP single password cookie based login without usernames. Categories : PHP , Cookies , Security , Beginner Guides Store, retrieve and delete cookies using JavaScript. Categories : Java Script , Cookies , Beginner Guides , Cookies Run a function once per session. Categories : Beginner Guides , Java Script , Cookies Using PHP im HTML image tags Categories : PHP , HTML and PHP , Graphics , Beginner Guides How to make sure a that $foo is from a cookie and not from the URI. Categories : PHP , Variables , Global Variables , Cookies How to display any array in several rows and columns of a table. Not just
in one column or in alternate rows. This example shows a nice color table
generated with PHP, but can be used with any array values(e.g. Database) Categories : Arrays , PHP , Miscellaneous , Beginner Guides , Graphics Secure Login Categories : PHP , MySQL , Cookies , Security Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP , Form Processing , PHP Classes , Data Validation , Beginner Guides Form Validation Using PHP to highlight non valid fields Categories : PHP , Form Processing , Data Validation , Beginner Guides Make old style (PHP3) scripts using GET, POST, COOKIE and File uploads (POST) compatible with
PHP 4.2.0 Categories : PHP , HTML and PHP , Global Variables , Cookies , Variables SQLite PHP Database Wrapper Categories : PHP , PHP Classes , Databases , SQLite , Beginner Guides a PHP Function to Get only the filename (remove the extension) using regular expressions. Categories : PHP , Regexps , Beginner Guides PHP Utilities - correct grammar helpers: the plural, to be and to have Categories : PHP , Utilities , Beginner Guides
Jason Hopkins wrote : 1818
Sorry for the low grade, but it should be common knowledge
to not break into and out of the PHP tags. Also, putting
an entire if construct on one line really irks me.