title: AJAX not submiting values to php
body: <p>I am trying to send the contact form values to php using JQuery Ajax.but when i hit the submit button, i am able to receive the success message, but the values are not received in php and is not stored in database. what may be the issue?</p>
  
  <p>here is what i have done</p>
  
  <p>HTML</p>
  
  <pre><code>                &lt;form name="contact-form" id="contact-me-form" method="POST"&gt;
                      &lt;div class="med-col form-element"&gt;
                          &lt;label for="uname"&gt;Name&lt;/label&gt;&lt;br&gt;
                          &lt;input type="text" class="form-input" name="uname" id="uname" required&gt;
                      &lt;/div&gt;
  
                      &lt;div class="med-col form-element"&gt;
                          &lt;label for="email"&gt;Email&lt;/label&gt;&lt;br&gt;
                          &lt;input type="email" class="form-input" name="email" id="email" required&gt;
                      &lt;/div&gt;
  
                      &lt;div class="lg-col form-element"&gt;
                          &lt;label for="msg"&gt;Message&lt;/label&gt;&lt;br&gt;
                          &lt;textarea name="msg" id="msg" class="comment-box" required&gt;&lt;/textarea&gt;
                      &lt;/div&gt;
                      &lt;div class="med-col form-element"&gt;
                          &lt;button class="contact-submit-button button button-black"&gt;&lt;i class="fa fa-paper-plane-o" aria-hidden="true"&gt;&lt;/i&gt; Send message&lt;/button&gt;
                      &lt;/div&gt;
                      &lt;div class="space30"&gt;&lt;/div&gt;
                  &lt;/form&gt;
  </code></pre>
  
  <p>PHP</p>
  
  <pre><code>&lt;?php
      $username = $_POST['uname'];
      $email = $_POST['email'];
      $message = $_POST['msg'];
  
      $servername = "localhost";
      $username = "user";
      $password = "#userpass#";
      $dbname = "sample";
      $conn = mysqli_connect($servername, $username, $password, $dbname);
      if (!$conn) {
          die("Connection failed: " . mysqli_connect_error());
      }
  
      $sql = "INSERT INTO contactdb (username, email, message) VALUES ($username,$email,$message)";
  
      if (mysqli_query($conn, $sql)) {
          echo "New record created successfully";
      } else {
          echo "Error: " . $sql . "&lt;br&gt;" . mysqli_error($conn);
      }
  
      mysqli_close($conn);
  ?&gt;
  </code></pre>
  
  <p>AJAX</p>
  
  <pre><code>    var form = $("#contact-me-form")
      var formdata = form.serialize()
      $('.contact-submit-button').click(function(){
          $.ajax({
            type: "POST",
            url: "contact-me.php",
            data: formdata,
            success: function(data) {
              alert("submitted successfully");
            }       
          });
          event.preventDefault();      
      })  
  </code></pre>