| || |
Join Date: Feb 2008
Re: Can anyone tell me how to code for website views that a website has got?
Well if you are using php, the below code might be very much useful for your purpose;
$filename = "hitsnum.txt";
$file = file($filename);
$file = array_unique($file);
$numhits = count($file);
$fd = fopen ($filename , "r");
$fstring = fread ($fd , filesize ($filename));
$fd = fopen ($filename , "w");
$fcount = $fstring."\n".getenv("REMOTE_ADDR");
$fout= fwrite ($fd , $fcount );
save this file as count.php. Now make a new file named numhits.txt and save both the count.php and the numhits.txt. Now upload all the files to the server and CHMOD numhits.txt to 777. After this is done, simply place the following code in your main page;
All done.. Now just enjoy your counter. Tell me if you need anything else. Happy to help you.