title: How to make an image-button run a PHP script?
body: <p>What's the best practice to create an image button that sends a value and runs a php script (that executes a mySQL query) when clicked. The button has to be an image and not a default submit type of button. I've been googling this for a few days and I still can't find a sutable answer. I could use GET and make a few image buttons (images with links that contain values) on the page that redirect to itself which then I can collect with</p>
  
  <pre><code>if (isset($_GET['variable'])) 
  </code></pre>
  
  <p>but I don't really want the user to see the values. I tried creating a form which has only one button in it that when clicked will reload the page and I could capture and use the value with</p>
  
  <pre><code>if (isset($_POST['submit_value'])) {$var = $_POST['submit_value']; }
  </code></pre>
  
  <p>but I can't seem to make this work, at least not when the button is an image. So if anyone knows a decent way to do this, please share. It doesn't have to be AJAX e.g. page reload is perfectly fine. I'm guessing that I need JavaScript to do this but I don't really know JavaScript so a working example would be nice.</p>
  
  <hr>
  
  <p>SELF-ANSWER</p>
  
  <p>Thank you for all of your answers. I found that the simplest working way to go with is to create a form with an input type of image that makes the submit and an input type of hidden that carries that value.</p>
  
  <pre><code>&lt;form action="some_page.php" method="POST"&gt;
      &lt;input type="hidden" name="variable" value="50" /&gt;
      &lt;input type="image" src="image.png" name="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And on the PHP side I use this to catch the value.</p>
  
  <pre><code>if (isset($_POST['variable'])) { $var = $_POST['variable']; }
  </code></pre>
  
  <p>This is the most suitable solution for my problem. Thank you all again for your speedy responses.</p>