title: Running PHP IF statement depending on specific HTML select form value
body: <p>I'm still new with <code>PHP</code> and I'm a bit stumped I'm afraid.</p>
  
  <p>I've searched everywhere and can't quite find a match.</p>
  
  <p>What I'm trying to do is run an <code>IF</code> based on the values of an <code>HTML</code> select form. Can anyone point me in the right direction?</p>
  
  <p>(I'm trying to setup a voting system. I can update the <code>MySQL</code> database using different submit buttons but I wish to use a select box instead.)</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form action='vote_action.php' method='post'&gt;
  &lt;select name="selectbox"&gt;
  &lt;option value=“optone”&gt;optone&lt;/option&gt;
  &lt;option value=“opttwo”&gt;opttwo&lt;/option&gt;
  &lt;/select&gt;
  &lt;input type='submit' name="submit" value=’submit’/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>if(isset($_POST['selectbox']))
  {
      if(isset($_POST[‘optone’]))
        {
          $vote_optone = "UPDATE mytable SET votes=votes+1 WHERE id=1";
  
          $run_optone = mysqli_query($con, $vote_optone);
  
          if($run_optone){
  
          echo “First updated“; 
                        }
          }
  
  
     if(isset($_POST[‘opttwo’]))
        {
          $vote_opttwo = "UPDATE mytable SET votes=votes+1 WHERE id=2”;
  
          $run_opttwo = mysqli_query($con, $vote_opttwo);
  
          if($run_opttwo){
  
          echo “Second updated“; 
                        }
          }
  
  
  }
  </code></pre>