title: How to change a PHP variable with a HTML button click?
body: <p>I am trying to change a PHP variable with either a HTML button click, or another appropriate way.</p>
  
  <p>Unfortunately, I am unable to post a majority of my code here, but I'll supply as much as possible.</p>
  
  <p>Firstly, I have two buttons on my site. They each call two different javascript functions, but they load the same HTML form. The form is then submitted to a MySQL database, depending on which button was clicked at the beginning.</p>
  
  <p>Instead of having both the buttons load the same form, I would like them to load different forms. I would like to do this by saving a PHP variable when the user clicks on either button.</p>
  
  <p>I have searched online quite a bit, but I found no direct answer to my question.</p>
  
  <p>Here is a slight example:</p>
  
  <p>HTML button to add a quiz:</p>
  
  <pre><code>&lt;h2&gt;
  &lt;button id='opener' class='roundButton add' value='' onClick="OpenNewQuizDialog();"&gt;
  &lt;/button&gt;
  Create Quiz
  &lt;/h2&gt;
  </code></pre>
  
  <p>HTML button to add a presentation:</p>
  
  <pre><code>&lt;h2&gt;
  &lt;button id='opener' class='roundButton add' value='' onClick="OpenNewPresDialog();
  &lt;/button&gt;
  Add Presentation
  &lt;/h2&gt;
  </code></pre>
  
  <p>Both Javascript functions:</p>
  
  <pre><code>function OpenNewQuizDialog()
  {
      $( "#dialog" ).dialog( "open" );
      $('#dialog').dialog({title:"Create Quiz"});
      $('#dialogtype').val("addquiz");
  }
  
  function OpenNewPresDialog()
  {
      $( "#dialog" ).dialog( "open" );
      $('#dialog').dialog({title:"Create Presentation"});
      $('#dialogtype').val("addpres");
  }
  </code></pre>
  
  <p>The HTML Form that is being opened:</p>
  
  <pre><code>&lt;div id="dialog" title="Edit Settings"&gt;
          &lt;form name="editForm" method="post" action="createplay.php"&gt;
          &lt;input type=hidden id='dialogid' name='dialogid' value=''&gt;
          &lt;input type=hidden id='dialogtype' name='dialogtype' value=''&gt;
          &lt;input type=hidden id='uid' name='uid' value='&lt;?php echo $userid; ?&gt;'&gt;
              &lt;div&gt;
              Name: &lt;input type='text' id='nameEdit' name='nameEdit' value=''&gt;
          &lt;/div&gt;
          &lt;div&gt;
              Data: &lt;textarea id='textEdit' name='textEdit' row='10' cols='50'&gt;&lt;/textarea&gt;
          &lt;/div&gt;
          &lt;input type="submit" class="roundButton upload" value="" /&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>What I have tried:</p>
  
  <p>I tried adding the following into the onClick part within the HTML buttons:</p>
  
  <pre><code>quiz button: &lt;?php $create_type = 'createquiz' ?&gt;
  presentation button: &lt;?php $create_type = 'createpres' ?&gt;
  </code></pre>
  
  <p>I then tried to make an 'if' statement to see which button was clicked, so I could show the appropriate form. Although, the value of $create_type was always 'createpres' since it was being called last on the page. It was like the PHP was being called, even though the HTML onClick was not being called.</p>
  
  <p>Is there a better way to approach this?</p>