title: How to send Json data into database using Jquery and Ajax?
body: <p>I have made form of customer details form when I click the button, It send Json data to customer. But my code is not inserting data into database. I am new in web technology, please tell me where I am wrong. </p>
  
  <p><strong>my Script:</strong></p>
  
  <pre><code> &lt;script&gt;   
      $(document).ready(function(){              
              $("#btnBooking").on("click", function(){                   
  
                  var uName = document.getElementById('userName').value;        
                  var mailId = document.getElementById('addressemailId').value;           
                  var mobNum = document.getElementById('userContactNumber').value;                    
                  $.ajax({
                      url:"http://192.168.1.11/customerhomes/customer.php", 
                      type:"GET", 
                      dataType:"json", 
                      data:{type:"booking",Name:uName, Email:mailId, Mob_Num:mobNum}, 
                      //type: should be same in server code, otherwise code will not run
                      ContentType:"application/json", 
                      success: function(response){ 
                              alert("13");                                                 
                          }, 
                          error: function(err){ 
                          alert(JSON.stringify(err)); 
                      } 
                  })              
              }); 
      });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>form in html</strong></p>
  
  <pre><code>&lt;body&gt;
      &lt;div class="page-header text-center"&gt;
          &lt;form &gt;
              &lt;div class="col-lg-8"&gt;                                  
                  &lt;div class="form-group"&gt;
                          &lt;label class="col-lg-3 control-label"&gt;Name:&lt;font style="color: red;"&gt;*&lt;/font&gt;&lt;/label&gt;
                          &lt;div class="col-lg-9"&gt;
                              &lt;input type="text" class="form-control" id="userName" name="userName" placeholder="Full Name" value=""&gt;
                          &lt;/div&gt;
                  &lt;/div&gt;
  
  
                  &lt;div class="form-group"&gt;
                      &lt;label class="col-lg-3 control-label"&gt;Mobile:&lt;font style="color: red;"&gt;*&lt;/font&gt;&lt;/label&gt;
                      &lt;div class="col-lg-9"&gt;
                          &lt;input type="text" class="form-control" id="userContactNumber" name="userContactNumber" type="number" placeholder="" onkeypress="enableKeys(event);" maxlength="10" placeholder="9966778888"&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;div class="form-group"&gt;
                          &lt;label class="col-lg-3 control-label"&gt;Email:&lt;font style="color: red;"&gt;*&lt;/font&gt;&lt;/label&gt;
                          &lt;div class="col-lg-9"&gt;                                  
                              &lt;input type="text" class="form-control" name="addressemailId" id="addressemailId" placeholder="you@example.com" value=""&gt;
                          &lt;/div&gt;
                  &lt;/div&gt;  
                  &lt;div class="form-group marg-bot-45"&gt;
                      &lt;label class="col-lg-3 control-label"&gt;&lt;/label&gt;
                      &lt;div class="col-lg-9"&gt;
  
                          &lt;a href="" class="btn btn-info"  id="btnBooking"&gt;Confirm Booking&lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p><strong>server code</strong> </p>
  
  <pre><code>&lt;?php
  header('Access-Control-Allow-Origin: *');//Should work in Cross Domaim ajax Calling request
  mysql_connect("localhost","root","1234");
  mysql_select_db("customer_details");
  if(isset($_GET['type']))
  {
      if($_GET['type']=="booking"){
          $name = $_GET ['Name'];
          $mail = $_GET ['Email'];
          $mobile = $_GET ['Mob_Num'];
          $query1 = "insert into customer(cust_name, cust_mobile, cust_email) values('$name','$mail','$mobile')";
          $result1=mysql_query($query1);
      }
  }
  else{
      echo "Invalid format";
  }
  </code></pre>