title: Post and submit problems using javascript, forms and php
body: <p>I am trying to create a validate-email javascript and get it working with forms and PHP. Of coures, some problems...</p>
  
  <ol>
  <li><p>As you can see in my form, I did define "post" as the method. But I can only retreive the data as if it was a get method. It was working before I started to add the e-mail verification script and adopt the code to it. </p></li>
  <li><p>If the e-mail is incorrect, I do return false. Isn't the point that the request to the test.php (defined in action) should not be executed? As it is now, the page is accessed even if I return false. </p></li>
  <li><p>Depending on the answers to the questions above, do I need to submit the form from the Javascript if the e-mail is verified ok? </p></li>
  </ol>
  
  <p>javascript: </p>
  
  <pre><code>function isValidEmail() {
      regExp = /^[a-zA-Z]+([_\.-]?[a-zA-Z0-9]+)*@[a-zA-Z0-9]+([\.-]?[a-zA-Z0-9]+)*(\.[a-zA-Z]{2,4})+$/;
   if(document.subscribe.email1.value.search(regExp) == -1){
            alert(document.subscribe.email1.value + " Incorrect email address");
      return false; 
      } 
  
  //document.subscribeForm.submit();
  
  return true; 
  }
  </code></pre>
  
  <p>php:</p>
  
  <pre><code>&lt;?php
  
  echo $_POST['email1'];
  
  $mysqli = mysqli_connect("localhost", "root", "", "test", "3306");
  
  $result = mysqli_query($mysqli, "SELECT email, id, subscriber, subscribed_date FROM `user` u;");
  
  while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
  foreach($row as $key =&gt; $value){
  
     echo "$key = $value&lt;BR/&gt;";
  }
  }
  
  mysqli_free_result($result);
  mysqli_close($mysqli);
  
  ?&gt;
  </code></pre>
  
  <p>html:</p>
  
  <pre><code>&lt;div id="subscribe"&gt;
    &lt;form action="test.php" name="subscribe" method=post"&gt;
      &lt;p id="formlabel"&gt;E-mail&lt;/p&gt; &lt;input type="text" name="email1"&gt;
      &lt;br&gt;
      &lt;p id="formlabel"&gt;Repeat e-mail&lt;/p&gt; &lt;input type="text" name="email2"&gt; &lt;br/&gt;
      &lt;input type="submit" value="Subscribe" onclick="isValidEmail()"&gt;
    &lt;/form&gt; 
  </code></pre>