Fri Feb 29, 2008 12:01 pm - PHP Turorial - Make Create Simple Web Page Text Counter HTML PHP Log Hits
#1849
PHP Turorial - Make Create Simple Web Page Text Counter HTML PHP Log Hits
ok, you have your site up and running. now how can you tell hove many visitors you are getting. Or whats more important you want to know how many page views or hits are you getting?
Than answer is simple, create a simple webpage counter.
What you need? You will need PHP, we recommend our friends at www.webune.com when it comes to php web hosting. they have excellent service. another thing you will need is a text editor to create your scripts. if you are using windows, you can use notepad.
so to have this counter working on your website, you will need two files and some code to put on your php website. so follow these steps:
1. Copy and Paste this code into notepad and save it as: counter.php
Code:
2. Open a blank notepad and type a 1 (one) on the first line and save it as: log.txt
3. Put this code at the bottom of your website:
Code:
You should have two files, counter.php & log.txt
IMPORTANT: If your website is being hosted in a Linux Server, its important to make your log.txt file writeable. Change the permissions to 777 because if you don't you will never see the counter change.
That's it, if you want to see it in action, our friends at www.webune.com have provided us with php web hosting to show you how this works:
CLICK HERE TO SEE DEMO
hope this helps. IF this has helped you a little bit, we would appreciate if you could put our wallpaperama.com link on your website? Why? We ask this because by you putting our link in your website more people will be able to get to this tutorials and learn just like you just did now. If you are at this page, you probably found it on a search engine, we want others to benefit from everyone's knowledge so we can all learn together.
Thanks
If you have any comments or questions you can reply.
Quote:
Than answer is simple, create a simple webpage counter.
What you need? You will need PHP, we recommend our friends at www.webune.com when it comes to php web hosting. they have excellent service. another thing you will need is a text editor to create your scripts. if you are using windows, you can use notepad.
so to have this counter working on your website, you will need two files and some code to put on your php website. so follow these steps:
1. Copy and Paste this code into notepad and save it as: counter.php
Code:
<?php
############################################################
############## http://www.wallpaperama.com ##############
############# Please Don't Remove This ##############
############################################################
# THIS FILES EDITS THE log.txt FILE TO UPDATE THE NUMBER PER HITS
// this will open the log.txt and writes to it
$visit = fopen("log.txt","r");
$counter = fgets($visit,1000);
fclose($visit);
$counter=$counter + 1 ;
echo "$counter" ;
// thies will update the log.txt file with the latest visit
$visit = fopen("log.txt","w");
fwrite($visit, $counter);
fclose($visit);
?>
############################################################
############## http://www.wallpaperama.com ##############
############# Please Don't Remove This ##############
############################################################
# THIS FILES EDITS THE log.txt FILE TO UPDATE THE NUMBER PER HITS
// this will open the log.txt and writes to it
$visit = fopen("log.txt","r");
$counter = fgets($visit,1000);
fclose($visit);
$counter=$counter + 1 ;
echo "$counter" ;
// thies will update the log.txt file with the latest visit
$visit = fopen("log.txt","w");
fwrite($visit, $counter);
fclose($visit);
?>
2. Open a blank notepad and type a 1 (one) on the first line and save it as: log.txt
3. Put this code at the bottom of your website:
Code:
<? include ("counter.php"); ?>
You should have two files, counter.php & log.txt
IMPORTANT: If your website is being hosted in a Linux Server, its important to make your log.txt file writeable. Change the permissions to 777 because if you don't you will never see the counter change.
That's it, if you want to see it in action, our friends at www.webune.com have provided us with php web hosting to show you how this works:
CLICK HERE TO SEE DEMO
hope this helps. IF this has helped you a little bit, we would appreciate if you could put our wallpaperama.com link on your website? Why? We ask this because by you putting our link in your website more people will be able to get to this tutorials and learn just like you just did now. If you are at this page, you probably found it on a search engine, we want others to benefit from everyone's knowledge so we can all learn together.
Thanks
If you have any comments or questions you can reply.
Quote:
html javascript strike box textphp lines in file strike source of monte cristo words in word counting file line php textlines in a file textscript character character lines file line cells with the number of lines in a file simple lines wallpaperama characters in script file lines of javascript number of lines in file cgi based word the of monte cristo box character edit word words in file unique lynx click counting crows message line in strike textjavascript web area every f in the following words in a message dynamic counting lines in a file php file for adobe indesign strike color box characters string counting crows colorblind lynx field character performance explain string value in the registry of monte cristo full characters counting words in asp file wallpaperama line editor indesign full words in a file based page characters in file letters in access words cgi bin textpl dynamic flash editor line serial editor character rows in file for quarkxpress the lines in a words in a box cells containing counting words in a line in file field wallpaperama the number of lines in a file vb einfacher textarea character how to lines in file character box word in find word for textfield countfield maxlimit char in strike small length function textrows number of characters in textpl number of lines file function textfield lines of file values words in rich box if specific counting cells with number of lines in a file file how to flash mx wallpaperama html tags textarea html tags flash mx cs 1.6 counterstrike textbox lines in flash mx 2004 128 latex html xsl flash javascript xslt character maps macromedia skins xml skins actionscript sty bots fla map animation figures xslt steam download maps math bots document flash wallpaperama graphics cs html length latex xsl map übersetzung characters characters page xml package image reference animation image help tags tag number kitchen begin graphics tutorials code deutsch javascript line 1.6 wallpaperama source font button tag figure eps font fla area 1.6 codes space tables area begin tutorial counters
author: web hosting