title: input type submit vs input type button
body: <p>I have been trying to solve an annoying behavior with PHP (I think..). Maybe some of you have encountered the same and have some ideas. I have an html form and I use an  element with the onClick event that calls a javascript function. Once the script's content has been processed, I execute the form.submit() directive. It basically checks common things like length of fields, etc. </p>
  
  <p>Now my problem is, when I use input type button, I set its name to submit1, and just to run a small test, I set the <code>&lt;form id="register" action="&lt;?php echo($PHP_SELF) ?&gt;" method="post"&gt;</code></p>
  
  <p>I then put: </p>
  
  <pre><code>        &lt;?php
  
  if (isset($_POST["submit1"])) {
      echo "Submit button was pressed";
      die();
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>However, I never see the message even though my input button's name is submit1. I then changed the input type to submit, and I click submit, I'll see the message but the only problem is that even if my javascript function finds any errors in the form, after clicking okay on the alert box, the form continues regardless. It only does this on submit type=submit. </p>
  
  <p>If anyone is interested,</p>
  
  <p>my buttons:
  1st try:</p>
  
  <pre><code>&lt;input type="button" name="submit1" class="submit" value="Register"      
  onclick="validateFields()"  /&gt;
  </code></pre>
  
  <p>2nd try:</p>
  
  <pre><code>&lt;input type="submit" name="submit1" class="submit" value="Create Account!"     
  onclick="validateFields()"  /&gt;
  </code></pre>