title: OnClick fopen fread fwrite fclose
body: <p>I have a image:</p>
  
  <pre><code> &lt;img src="imagini/floo.gif" onclick="score()"&gt;
  </code></pre>
  
  <p>and i want "on click" to be opened a file "c.txt".
  That file's content is:
  0</p>
  
  <p>And i want on every click, to be added 100 in c.txt.</p>
  
  <p>I want something like this:</p>
  
  <pre><code> &lt;img src="imagini/floo.gif" onclick="score()"&gt;
  &lt;script&gt; function score(){ (..do file add.php ...) }&lt;/script&gt;
  </code></pre>
  
  <p>And add.php:</p>
  
  <pre><code>&lt;?php
  $c = "c.txt";
  $fh = fopen($c, "r");
  $current = fread($fh, filesize($c));
  fclose($fh);
  $current++;
  $fh = fopen($c, "w");
  fwrite($fh,$current);
  fclose($fh);
  ?&gt;
  </code></pre>
  
  <p>What to put in place: "(..do file add.php ...)" for the code to work?</p>