|
|
|
|
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); } ?> |
|
| Store, retrieve and delete cookies using JavaScript. Categories : Java Script, Cookies, Beginner Guides, Cookies | | | 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 | | | Simple PHP Form Field Generator Categories : PHP, Beginner Guides, Form Processing, HTML and PHP | | | Script loading time Categories : PHP, Beginner Guides, Date Time | | | Different Call User Functions Categories : PHP, Functions, Beginner Guides | | | Reverse a given number Categories : PHP, Beginner Guides, Algorithms, Math. | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | How to Insert a Date Format Into MySQL from PHP Categories : PHP, Databases, MySQL, Date Time, Beginner Guides | | | This functions makes it easy to use session-variables known from ASP. With one Cookie the array "session" will save and restore from a db-record. In this version MySQL is used but it's should very easy to change Categories : PHP, Arrays, Cookies, MySQL, Databases | | | Human readable PHP password generator Categories : PHP, Security, Beginner Guides, Arrays | | | Random text quote Categories : PHP, Arrays, Beginner Guides | | | Newbie Notes #10 - Generating drop downs Categories : PHP, MySQL, HTML, Beginner Guides, Databases | | | session out Timer Categories : PHP, Sessions, Security, 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.
| |
|
|