Helpful Information
 
 
Category: Scripts
recording number of clicks

I would like to record how many times peopple click this one link i have on my website is there a php script that does that or some sort of cgi script?:confused:

Moved from PHP forum to Scripts forum

Did you check Hotscripts, Sourceforge, Google... ?

Originally posted by amorpheus
I would like to record how many times peopple click this one link i have on my website is there a php script that does that or some sort of cgi script?:confused:

Do you still need help?

If it's just one link, you could change it to redirect to (for instance) 'hit.php'.
You would need to have a 'hits.txt' file with 666 access (CHMOD 666 hits.txt)

hit.php:


<?php
## Open hits counter to get current count ##
$fH = @fopen('hits.txt', 'r');

## Only save new count if it opened ##
if ($fH)
{
$count = fgets($fH, 1024);
@fclose($fH);

## Add one to count (or restart if corrupt) ##
if (is_numeric($count))
$count++;
else
$count = 1;

## Only save if possible ##
$fH = @fopen('hits.txt', 'w');
if ($fH)
fputs($count . "\n");
@fclose($fH);
}

## Redirect ##
header('Location: http://new/url/');
?>


Of course, if you're talking about many links, I'd suggest using a database back-end.

Hope this helps

hmm thanx...what does the txt file suposed to look like?
:confused: i tested the link out but it doesnt record it to txt...and im running my own apache webserver on windows so..chmod i dont think is available so how do i deal with that?

As far as I know, you shouldn't have any problems with write properties on windows.

The text file should create itself. If not, try creating a blank hits.txt (or whatever).
It's possible Apache isn't letting you create new files.

If you take the '@' symbols off while debugging, it should give you some extra info.

it doesnt log anything to hit.txt....

Have you tried removing the '@' symbols to see if any errors are produced?

It should tell you if the file cannot be read or written to, for any reason.

Lot of click tracking scrupts out there !!at hotscripts !!

Originally posted by Wite_Noiz
Do you still need help?

If it's just one link, you could change it to redirect to (for instance) 'hit.php'.
You would need to have a 'hits.txt' file with 666 access (CHMOD 666 hits.txt)

hit.php:


<?php
## Open hits counter to get current count ##
$fH = @fopen('hits.txt', 'r');

## Only save new count if it opened ##
if ($fH)
{
$count = fgets($fH, 1024);
@fclose($fH);

## Add one to count (or restart if corrupt) ##
if (is_numeric($count))
$count++;
else
$count = 1;

## Only save if possible ##
$fH = @fopen('hits.txt', 'w');
if ($fH)
fputs($count . "\n");
@fclose($fH);
}

## Redirect ##
header('Location: http://new/url/');
?>


Of course, if you're talking about many links, I'd suggest using a database back-end.

Hope this helps

Didnt work..:(

Error:
Warning: Wrong parameter count for fputs() in /mnt/home3/b/ba/banan289/public_html/m-eye/gbcount.php on line 20

Warning: Cannot add header information - headers already sent by (output started at /mnt/home3/b/ba/banan289/public_html/m-eye/gbcount.php:20) in /mnt/home3/b/ba/banan289/public_html/m-eye/gbcount.php on line 25










privacy (GDPR)