title: AJAX call return success message but post data never insert into db
body: <p>I have suggestion.php form as follow and call the ajax method. I always got "Thanks you" alert but post data never insert into db. I am very sure that my connection string is correct because it is sometime insert the record but most of the time it is not inserted.</p>
  
  <p>Any help, please.
  Regards,
  Alex</p>
  
  <p>suggestion.php</p>
  
  <pre><code>&lt;form class="suggestion" role="form" method="POST" action="suggestion_add.php"&gt;
        &lt;div class="form-group"&gt;&lt;label name="warnning" id="urlwarnning"&gt;Currently we only support YouTube as well as Vimeo videos&lt;/label&gt;&lt;/div&gt;
        &lt;div class="form-group"&gt;&lt;input name="url" id="url" type="text" class="form-control" placeholder="URL" required&gt;&lt;/div&gt;
        &lt;div class="form-group"&gt;&lt;input name="title" id="title" type="text" class="form-control" placeholder="Title" required&gt;&lt;/div&gt;
        &lt;div class="form-group"&gt;&lt;textarea id="desc" name="desc" class="form-control" rows="5" placeholder="Description.." required&gt;&lt;/textarea&gt;&lt;/div&gt;
        &lt;div class="form-group"&gt;&lt;input name="name" id="name" type="text" class="form-control" placeholder="Name" required&gt;&lt;/div&gt;
        &lt;div class="form-group"&gt;&lt;input name="email" id="email" type="text" class="form-control" placeholder="Email ID" required&gt;&lt;/div&gt;
        &lt;button class="btn btn-lg btn-primary btn-block" type="submit"&gt;SUBMIT&lt;/button&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>Function</p>
  
  <pre><code>$(function () {
      $(document).on('submit', ".suggestion", function(e) {
          var name=$("#name").val();
          var email=$("#email").val();
          var url=$("#url").val();
          var title=$("#title").val();
          var desc=$("#desc").val();
          var formURL = $(this).attr("action");
          var youtube_regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&amp;v=)([^#\&amp;\?]*).*/;
          var vimeo_regExp = /https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/;
          var match = url.match(youtube_regExp);
          if (match&amp;&amp;match[2].length==11){
              var vid = match[2];
              var src = "youtube";
              var check = 1;
          }else{
              var match = url.match(vimeo_regExp);
              if (match){
                  var vid = match[3];
                  var src = "vimeo";
                  var check = 1;
              }else{
                  alert("not a valid url");
                  var check = 0;
  
              }
          }
          if(check == 1){
              var data="title="+title+"&amp;desc="+desc+"&amp;src="+src+"&amp;vid="+vid+"&amp;name="+name+"&amp;email="+email;
  
              $.ajax(
              {
                  url : "suggestion_add.php",
                  type: "POST",
                  data : data,
                  success:function(data, textStatus, jqXHR)
                  {
                      $("#name").val("");
                      $("#email").val("");
                      $("#url").val("");
                      $("#title").val("");
                      $("#desc").val("");
                      alert("Thank you !");
  
                  },
                  error: function(jqXHR, textStatus, errorThrown)
                  {
              alert(errorThrown);
                  }
              });
          }else{
              alert("Check again!");
          }
          e.preventDefault();
      });
  
  });
  </code></pre>
  
  <p>suggestion_add.php</p>
  
  <pre><code>&lt;?php
  include("config.php");
  $con=mysql_connect($db_host,$db_uname,$db_pwd,$db_name);
  mysql_select_db($db_name);
  $src=$_POST['src'];
  $name=$_POST['name'];
  $email=$_POST['email'];
  $title=$_POST['title'];
  $desc=$_POST['desc'];
  $vid=$_POST['vid'];
  $query="INSERT INTO `suggestion` (`id`,`src`,`vid`,`title`,`desc`,`name`,`email`)VALUES (NULL,'$src','$vid','$title','$desc','$name','$email');";
  $result=mysql_query($query);
  ?&gt;
  </code></pre>