PHP is giving me error of
Notice: Undefined index: product_id in C:\xampp\htdocs\odieinventory\admin\add_sales.php on line 6
This is my query
<?php 
  if (isset($_POST['addCart'])) {
    $product_id = $_POST['product_id'];
    $qtyBuy = $_POST['qtyBuy'];
    $addQuery = "INSERT INTO sales (product_id, quantity) VALUES ($product_id, $qtyBuy)";
    $execQuery = mysqli_query($connection, $addQuery);
  }
?>
This is my table
<form action="add_sales.php" method="POST">
        <?php 
          $query = "SELECT * FROM products";
          $exec = mysqli_query($connection, $query);
          while ($row = mysqli_fetch_array($exec)) {
            $product_id = $row['product_id'];
            $product_name = $row['product_name'];
            $description = $row['description'];
            $product_quantity = $row['quantity'];
            $product_price = $row['sell_price'];
         ?>
            <tr>
                <td class="text-center"><?php echo $product_id; ?>
                  <input type="hidden" name="product_id" value="<?php echo $product_id; ?>">
                </td>
                <td><?php echo $product_name; ?></td>
                <td><?php echo $description; ?></td>
                <td><?php echo $product_price; ?></td>
                <td><?php echo $product_quantity; ?></td>
                <td><input type="number" min="1" max="999" name="qtyBuy"></td>
            </tr>
         <?php } ?>
        </tbody>
      </table>
      </div>
      <div class="form-group">
          <input type="submit" name="addCart" value="Add Items to Cart" class="btn btn-info pull-right">
      </div>
   </div>
</form>

I would also like to ask for advice on how to insert records on my cart. By clicking 'Add Items to Cart', I like to pass ONLY the items with values on the quantitiy input on the cart. How to achieve this with PHP?
 
     
     
     
    