title: HTML button submit not activating php code
body: <p>I am having an issue with my html forms not submitting properly. I am new to forms and have been trying to get a login script going but it has been failing. I am using chrome mostly. Here is the super dumbed down code that hopefully demonstrates my issue. I am guessing what is wrong in this code is in the extended code. This is the website I used for my login coding: <a href="http://www.codingcage.com/2015/04/php-login-and-registration-script-with.html" rel="nofollow noreferrer">login account setup site mainly for reference</a></p>
  <pre><code>&lt;?php
  
  //this is here for testing
  session_start();
  
  //this shows
  echo &quot;something&quot;;
  
  //none of these show
  if(isset($_POST['submit'])){
  
      echo &quot;something&quot;;
      echo &quot;something&quot;;
      echo &quot;something&quot;;
      echo &quot;something&quot;;
  }
  if(isset($_POST['submit2'])){
  
      echo &quot;something&quot;;
      echo &quot;something&quot;;
      echo &quot;something&quot;;
      echo &quot;something&quot;;
  }if(isset($_POST['submit3'])){
  
      echo &quot;something&quot;;
      echo &quot;something&quot;;
      echo &quot;something&quot;;
      echo &quot;something&quot;;
  }
  
  ?&gt;
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
  &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot;&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;footer&gt;
      &lt;!-- I have tried it with and without an action --&gt;
      &lt;form action=&quot;button_test.php&quot; method=&quot;post&quot; id=&quot;this&quot; style=&quot;width: 100%; height: 100%; background-color: darkblue;&quot;&gt;
          &lt;button type=&quot;submit&quot; name=&quot;submit&quot; id=&quot;submit&quot; class=&quot;button&quot; value=&quot;Submit&quot;&gt;this is something&lt;/button&gt;
          &lt;button type=&quot;button&quot; name=&quot;submit2&quot; id=&quot;submit2&quot; class=&quot;button&quot; value=&quot;this&quot;&gt;this is something2&lt;/button&gt;
          &lt;input type=&quot;button&quot; name=&quot;submit3&quot; id=&quot;submit3&quot; class=&quot;button&quot; value=&quot;true&quot;/&gt;
      &lt;/form&gt;
  &lt;/footer&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>The first button predictably reloads the page, while the others do nothing. This is the extended main code that I need working. Once again, I am guessing the code above probably explains what is wrong with the code beneath. The code beneath is primarily there to give context and more accurate answers.</p>
  <pre><code>&lt;?php
  
  //require once the DatabaseController.php file,
  require_once 'Controllers/DatabaseController.php';
  echo &quot;this happend1&quot;;
  // Creates a data connect object that creates a connection to
  // a database
  $connection = new DataConnect;
  //Run the user_load function to set the user
  $connection-&gt;user_load();
  echo &quot;this happend2&quot;;
  /*
   * Runs the in_loggedin function from a
   * user object and checks if it is blank
   */
  if($user-&gt;is_loggedin()!=&quot;&quot;)
  {
      echo &quot;this happend3&quot;;
      //return user to logged in home page if
      //they are logged in
      $user-&gt;redirect('index.php');
  }
  echo &quot;this happend4&quot;;
  /*
   * THIS DOES NOT WORK FOR SOME REASON
   */
  if(isset($_POST['btn-login']))
  {
      echo &quot;this happend5&quot;;
      //Load the variables with the new form data that has been executed
      $uname = $_POST['txt_uname_email'];
      $umail = $_POST['txt_uname_email'];
      $upass = $_POST['txt_password'];
  
      //If the user-&gt;login call is successful, go to home fully logged in
      if($user-&gt;login($uname,$umail,$upass))
      {
          //Go to home, fully logged in
          $user-&gt;redirect('index.php');
      }
      else
      {
          //Error
          $error = &quot;Wrong Details !&quot;;
      }
  }
  ?&gt;
  
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en-US&quot;&gt;
      &lt;head&gt;
          &lt;meta charset=&quot;UTF-8&quot;&gt;
          &lt;title&gt; Josiah&lt;/title&gt;
  
          &lt;link href=&quot;Assets/Stylesheets/styles-home.css&quot; type=&quot;text/css&quot; rel=&quot;stylesheet&quot; /&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;?php
          include_once 'header.php';
          ?&gt;
  
  &lt;!-- recent blog post: contains the most recent blog post--&gt;
  &lt;div id=&quot;main-content&quot; class=&quot;content&quot;&gt;
      &lt;div id=&quot;main-content-inner&quot; class=&quot;inner-content&quot;&gt;
          &lt;!-- this is the container for the form --&gt;
          &lt;div class=&quot;form-container&quot;&gt;
              &lt;!-- create a form that uses the &quot;post&quot; method which allows php to do $_POST on
              corresponding variable names --&gt;
              &lt;form method=&quot;post&quot;&gt;
  
                  &lt;h2&gt;Sign in.&lt;/h2&gt;&lt;hr /&gt;
                  &lt;!-- checks if there was an error. If the error variable is set --&gt;
                  &lt;?php
                  if(isset($error))
                  {
                      ?&gt;
                      &lt;!-- displays the error --&gt;
                      &lt;div class=&quot;alert alert-danger&quot;&gt;
                          &lt;i class=&quot;glyphicon glyphicon-warning-sign&quot;&gt;&lt;/i&gt; &amp;nbsp; &lt;?php echo $error; ?&gt; !
                      &lt;/div&gt;
                      &lt;?php
                  }
                  ?&gt;
                  &lt;!-- this is a form-group --&gt;
                  &lt;div class=&quot;form-group&quot;&gt;
                      &lt;!-- this is a text input. --&gt;
                      &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;txt_uname_email&quot; placeholder=&quot;Username or E mail ID&quot; required /&gt;
                  &lt;/div&gt;
                  &lt;!-- this is a form-group --&gt;
                  &lt;div class=&quot;form-group&quot;&gt;
                      &lt;!-- this is a text input. --&gt;
                      &lt;input type=&quot;password&quot; class=&quot;form-control&quot; name=&quot;txt_password&quot; placeholder=&quot;Your Password&quot; required /&gt;
                  &lt;/div&gt;
                  &lt;!-- splits parts of the form --&gt;
                  &lt;div class=&quot;clearfix&quot;&gt;&lt;/div&gt;&lt;hr /&gt;
                  &lt;!-- this is a form group holdng the submit button --&gt;
                  &lt;div class=&quot;form-group&quot;&gt;
                      &lt;!-- the button interestingly has multiple classes --&gt;
                      &lt;button type=&quot;submit&quot; name=&quot;btn-login&quot; class=&quot;btn btn-block btn-primary&quot;&gt;
                          &lt;!-- splits parts of the form. Dont know specifically what this does. --&gt;
                          &lt;i class=&quot;glyphicon glyphicon-log-in&quot;&gt;&lt;/i&gt;&amp;nbsp;SIGN IN
                      &lt;/button&gt;
                  &lt;/div&gt;
                  &lt;br /&gt;
                  &lt;label&gt;Don't have account yet ! &lt;a href=&quot;sign-up.php&quot;&gt;Sign Up&lt;/a&gt;&lt;/label&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;!-- footer: contains social media, site map, and an up arrow--&gt;
  &lt;?php
  include 'footer.php'
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>