Re: Keep track of page-access [message #172897 is a reply to message #172889] |
Fri, 11 March 2011 10:10 |
Beauregard T. Shagnas
Messages: 154 Registered: September 2010
Karma:
|
Senior Member |
|
|
sl@exabyte wrote:
> Beauregard T. Shagnasty wrote:
>> sl@exabyte wrote:
>>> After some searching I intend to use AJAX and PHP to keep track of
>>> the number of times an HTML file (just a single file) has been
>>> accessed.
>>
>> AJAX not necessary. Just use a bit of PHP in the file to do
>> something simple like update a database .. a counter.
>>
>> Or as Doug says, look at your server logs.
>
> I suppose for PHP alone, the HTML file must end with ".php"
> extension.
...and for PHP and AJAX, too. <g> No, it does not need to be a ".php"
file extension. You can direct your "filename.html" to be processed as
PHP, via a simple line in your .htaccess file. (Assuming an Apache
server)
> For server logs alone, would it a problem if I need to keep the
> counter over, say, a few years. I hope not to clear the log every
> month.
Answered by others...
But my choice would be a dozen lines of PHP and a MySQL database table.
For "just a counter" you could simply increment a number (field) in a
one-row table, or you could add and store a new row for each page hit,
including further information such as visitor's IP address, browser UA
string, etc.
--
-bts
-Four wheels carry the body; two wheels move the soul
|
|
|