title: PHP making a download counter without leaving the current page
body: <p>I tried to create a download counter with PHP.
  The script, I have created, works, but when I click the download link, the script sends me to a blank page. Is it possible to stay on the page while downloading and counting?</p>
  
  <p>Here's my code of my download.php file:</p>
  
  <pre><code>&lt;?php
  $Down=$_GET['Down'];
  ?&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;meta http-equiv="refresh" content="0;url=&lt;?php echo $Down; ?&gt;"&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;?php
  
  $fp = fopen("counter.txt", "r");
  $count = fread($fp, 1024);
  fclose($fp);
  $count = $count + 1;
  
  $fp = fopen("counter.txt", "w");
  fwrite($fp, $count);
  fclose($fp);
  
  
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>That's how the link in my index.php looks like:</p>
  
  <pre><code>&lt;a href="download.php?Down=download.zip"&gt;download&lt;/a&gt;
  </code></pre>
  
  <p>Many thanks in advance!</p>