title: how can I insert into sql table using javascript
body: <p>// HOW CAN I INSERT INTO SQL TABLE USING JAVASCRIPT
  how can I insert  into sql table using javascript</p>
  <pre><code>        function checkout() {
  </code></pre>
  <blockquote>
  <p>enter code here</p>
  </blockquote>
  <p>`// HOW CAN I INSERT INTO SQL TABLE USING JAVASCRIPT
  how can I insert  into sql table using javascript</p>
  <pre><code>        function checkout() {
            var ajax = new XMLHttpRequest();
            var method = 'GET';
            var url = 'test.php';
            var asynchronous = 'true';
            ajax.open(method, url, asynchronous);
            ajax.send();
  
            var customer_fname = document.getElementById('customer_fname').value;
            var customer_lname = document.getElementById('customer_lname').value;
            var customer_phone = document.getElementById('customer_phone').value;
            var area = document.getElementById('area_id').value;
            var address = document.getElementById('address_1').value;
            var order_notes = document.getElementById('order_notes').value;
            var cutting_price = document.getElementById('td_cutting_price').innerHTML;
            var wallet_price = document.getElementById('td_wallet_price').innerHTML;
            var sub_total = document.getElementById('td_sub_price').innerHTML;
            var total = document.getElementById('td_total_price').innerHTML;
            var invoice = '#' + (Math.floor(Math.random() * 10000) + 1);
            var order_time = new Date();
            
            
  
  
  
            //receiving response from testphp
            ajax.onreadystatechange = function() {
              if (this.readyState == 4 &amp;&amp; this.status == 200) {
                var data = JSON.parse(this.responseText);
  
  
                for (var a = 0; a, data.length; a++) {
                  var product_id = data[a].product_id;
                  var product_size = data[a].product_size;
                  var customer_email = data[a].customer_email;
                  var product_title = data[a].product_title;
  
                  // I WANT TO insert SOME OF THE ABOVE VARIABLE INTO MY pending_orders Table
                
  
  
  
                }
  
  
              }
  
            }
          }
        
  
        &lt;div class=&quot;form-group mt-5&quot;&gt;
          &lt;a name=&quot;checkout&quot; type=&quot;button&quot; id=&quot;checkout&quot; class=&quot;btn btn-outline-primary btn-sm btn-block&quot; style=&quot;border-color:#ec7f37;background-color: #ec7f37; color:#fff&quot; onclick=&quot;checkout();&quot;&gt; Checkout&lt;/a&gt;
  
  
  
        &lt;/div&gt;
  </code></pre>