TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   Can anyone tell me how to code for website views that a website has got? (http://forums.techarena.in/software-development/1267430.htm)

SoftWore 05-11-2009 03:32 PM

Can anyone tell me how to code for website views that a website has got?
 
Hi, i am new to web development, but am looking for a code that would help me determine how many visitors my website got? Can anyone please give me n example to explain, how this is done..? Thanks in advance guys.:rolleyes:

MindSpace 05-11-2009 03:49 PM

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;
Code:

<?php
$filename = "hitsnum.txt";

$file = file($filename);
$file = array_unique($file);
$numhits = count($file);
echo $numhits;

$fd = fopen ($filename , "r");
$fstring = fread ($fd , filesize ($filename));
fclose($fd);
$fd = fopen ($filename , "w");
$fcount = $fstring."\n".getenv("REMOTE_ADDR");
$fout= fwrite ($fd , $fcount );
fclose($fd);
?>

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;
Code:

<?php
include ('counter.php');
?>

All done.. Now just enjoy your counter. Tell me if you need anything else. Happy to help you.

medicalseo 05-11-2009 08:44 PM

Can anyone please give me n example to explain, how this is done..? :thumbup1:


All times are GMT +5.5. The time now is 06:20 PM.