How can I run a PHP counter script when clicking a link?
<p>I have a script that runs when a page is visited on my site, it updates a value and stores it in a text file, but I want to run the same script when a link is clicked on my site, this link just opens a file in my web directory, not an actual page. here is teh script:</p>

<pre><code>&lt;?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);

?&gt;
</code></pre>

<p>So if I want to run this when my link is clicked does anyone know where I would do this? Here is an example of my link:</p>

<pre><code>&lt;li&gt;&lt;a href="files/file.pdf" target="blank" title="File"&gt;File&lt;/a&gt;&lt;/li&gt;
</code></pre>

<p>So this link opens the file in a new tab, I am busting my brains trying to figure out how to run this from the link click, any advice would be appreciated.</p>

<p>I was thinking about calling a PHP function which ran the code when the link was clicked, but I couldn't do it.</p>

<p>Many thanks!</p>
