title: php not inserting data into table
body: <p>I have a HTML form </p>
  
  <pre><code>&lt;div class="contact-form col-md-6 " &gt;
                  &lt;form id="contact-form" method="post" action="" role="form"&gt;
  
                      &lt;div class="form-group"&gt;
                        &lt;input type="text" placeholder="Your Name" class="form-control" name="name" id="name" required&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group"&gt;
                          &lt;input type="email" placeholder="Your Email" class="form-control" name="email" id="email" required&gt;
                      &lt;/div&gt;
  
                      &lt;div class="form-group"&gt;
                          &lt;input type="text" placeholder="Your Phone Number" class="form-control" name="phone" id="phone" required&gt;
                      &lt;/div&gt;                  
                      &lt;div class="response_msg"&gt;&lt;/div&gt;
                      &lt;div id="mail-success" class="success"&gt;
                          Thank you. You are registerd. :)
                      &lt;/div&gt;
  
                      &lt;div id="mail-fail" class="error"&gt;
                          Sorry, don't know what happened. Try later :(
                      &lt;/div&gt;
  
                      &lt;div id="cf-submit"&gt;
          &lt;input type="submit" id="contact-submit" class="btn btn-transparent" value="Register" name="submit"&gt;
                      &lt;/div&gt;                                          
                  &lt;/form&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>I need to submit form on same page and show message on successfully submission. I am using JS for this</p>
  
  <pre><code>&lt;script&gt; 
  $(document).ready(function(){
  $("#contact-form").on("submit",function(e){
  e.preventDefault();
  if($("#contact-form [name='name']").val() === '')
  {
  $("#contact-form [name='name']").css("border","1px solid red");
  }
  else if ($("#contact-form [name='email']").val() === '')
  {
  $("#contact-form [name='email']").css("border","1px solid red");
  }
  else if ($("#contact-form [name='phone']").val() === '')
  {
  $("#contact-form [name='phone']").css("border","1px solid red");
  }
  else
  {
  $("#loading-img").css("display","block");
  var sendData = $( this ).serialize();
  $.ajax({
  type: "POST",
  url: "js/ajaxsubmit.php",
  data: sendData,
  success: function(data){
  $("#loading-img").css("display","none");
  $(".response_msg").text(data);
  $(".response_msg").slideDown().fadeOut(3000);
  $("#contact-form").find("input[type=text], input[type=email], textarea").val("");
  }
  
  });
  }
  });
  
  $("#contact-form input").blur(function(){
  var checkValue = $(this).val();
  if(checkValue != '')
  {
  $(this).css("border","1px solid #eeeeee");
  }
  });
  });
  &lt;/script&gt;  
  </code></pre>
  
  <p>As soon i clicked on submit button page refresh but my i don't see my pho code inserting data in database.</p>
  
  <pre><code>&lt;?php 
  require_once("conn.php");
  if((isset($_POST['name'])&amp;&amp; $_POST['name'] !='') &amp;&amp; (isset($_POST['email'])&amp;&amp; $_POST['email'] !='') &amp;&amp; (isset($_POST['phone'])&amp;&amp; $_POST['phone'] !=''))
  {
  // require_once("contact_mail.php");
  
      $yourName = $conn-&gt;real_escape_string($_POST['name']);
      $yourEmail = $conn-&gt;real_escape_string($_POST['email']);
      $yourPhone = $conn-&gt;real_escape_string($_POST['phone']);
      $sql="INSERT INTO Beta_Registration (name, email, phone) VALUES ('".$yourName."','".$yourEmail."', '".$yourPhone."')";
      if(!$result = $conn-&gt;query($sql)){
      die('There was an error running the query [' . $conn-&gt;error . ']');
      }
      else
      {
      echo "Thank you! We will contact you soon";
      }
      }
      else
      {
      echo "Please fill Name and Email";
      }
      ?&gt;
  </code></pre>
  
  <p>I want my form to submit on same page also stays on same block and shows the messages in <code>div</code> inside form when data entered successfully or failed into database. </p>
  
  <p>The issues i am facing whenever i press submit button it refreshed the page and form data doesn't executed into database. It might be php or JS i am using. Please help me in this.</p>