This is my Jquery that is capable of Inserting
$(function(){
$(document).on('click', '#addRefBtn', function(e){
   var get_input = $('#qr_ref').val();
   var get_po = $('#get_po').val();
   location.reload();
     $.ajax({
            type: 'POST',
            url: 'validate_qr.php',
            data: {
            qr_code:get_input,
            po_ID: get_po
            },
           success: function(result){
           // console.log(result);
           },
          error: function(result){
          }
       });
     });
   });
and this is my Url in ajax that is compose of my query that is inserting and also I want to update
                        $query = $conn->prepare("INSERT INTO product_sales (product_id, client_id, po_ID, unitPrice, sales_date, updated_date,                                   invoiceTerminated, reference_no, status) 
                                             VALUES (:product_id, :client_id, :po_ID, :unitPrice, :sales_date, :updated_date, :invoiceTerminated, :reference_no, :status)");
                    $query->execute([
                                        'product_id'=> $product_id, 
                                        'client_id'=> $client_id, 
                                        'po_ID'=> $po_ID, 
                                        'unitPrice'=> $etc_price,
                                        'sales_date'=> $date,
                                        'updated_date'=> $updated_date,
                                        'invoiceTerminated'=> $invoiceTerminated,
                                        'reference_no'=> $New_ref_no,
                                        'status'=> $status
                                    ]);
                    $queryUpdate = $conn->prepare("UPDATE backup_sales t1 
                                                   JOIN product t2 ON (t1.model_id = t2.model_id) 
                                                   SET t1.status = '1', 
                                                    t2.prod_status = '1' 
                                                   WHERE t1.po_ID = ':po_ID'
                                                   AND t2.model_id = ':product_id'");
                    $queryUpdate->execute(['po_ID'=>$po_ID, 'product_id'=>$product_id]);
Is my approach correct? Am i missing something? Kindly correct me, thanks.
 
     
    