title: HTML form submit only registers clicks sporadically - why?
body: <p>I have a PHP site, where a central functionality is clicking one of two buttons on a page. Quite simple. Based on which button is clicked, different values are stored in a database.</p>
  
  <p>Initially I used two <code>&lt;Button&gt;</code> elements in the same form, but as this doesn't seem to be compatible with all browsers, I use two forms instead. While the code might not be necessary (It works), I provide it anyway. For the actual problem, please scroll down. The forms are defined thus:</p>
  
  <pre><code>&lt;form method='post' action='index.php'&gt;
    &lt;input type='hidden' name='confirm' value='1'/&gt;
    &lt;input type='hidden' name='id' value='1'/&gt;
    &lt;input type='submit' value='Include'/&gt;
  &lt;/form&gt;
  &lt;form method='post' action='index.php'&gt;
    &lt;input type='hidden' name='confirm' value='-1'/&gt;
    &lt;input type='hidden' name='id' value='1'/&gt;
    &lt;input type='submit' value='Exclude'/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And the corresponding POST-reading section in index.php:</p>
  
  <pre><code>if (filter_has_var(INPUT_POST,"confirm")) {
    $msi = connectDB(); //Creates and returns a mysqli connection
    $c = filter_input(INPUT_POST,"confirm");
    $id = filter_input(INPUT_POST,"id");
    mysqli_query($msi,"UPDATE `table` SET `confirm` = $c WHERE `id` = $id");
    header("Location: index.php");
  }
  </code></pre>
  
  <p>Now... this works exactly as intended - the table is updated with the <code>confirm</code>-value that was clicked. And when running this on my localhost setup, there are no problems at all.</p>
  
  <p>However, once I launched this on the production website, the submit buttons will only fire occasionally. Once a user clicks either submit button, they are shown a new page, with the same buttons and a new ID - so the page is displayed many times, and sometimes it works on the first click on either button, but most of the times nothing happens when clicking (although perhaps it refreshes the page - I am unsure of this). Any suggestions?</p>
  
  <p>EDIT:
  A little more information, and the reason why I know it doesn't "fire":</p>
  
  <p>Whenever this page loads, it selects a random ID from <code>table</code>, where <code>confirm</code> is 0, i.e. not confirmed yet. It then displays some information based on this ID. The PHP then loads a new page, with a new random ID. In other words, whenever either submit is clicked, it should change the <code>confirm</code>-value of the current ID to something different from 0, and the same ID will never be displayed again. And in the localhost-development setting, that is the case - but in the live setting, the page sometimes refreshes, showing the same information, not updating the <code>confirm</code>-value. If the user clicks the same button again, it might perform correctly - it appears to be rather random.</p>
  
  <p>EDIT 2 - <strong>FIXED</strong>:
  I had a suspicion that since it worked in dev, and not in live, the error must be found there. So after discussing it with a coworker, I searched for server cache problems with my server host, and it turns out others are having similar problems. The fix was adding the following lines to <code>.htaccess</code>:</p>
  
  <pre><code>RewriteEngine on
  RewriteRule (.*) - [E=Cache-Control:no-cache] 
  </code></pre>
  
  <p>Thank you to those who took the time to respond.</p>