title: Adding product to shopping cart not working
body: <p>When I click on add to cart, It's not working although the button change from 'Add to cart' to 'Adding' meaning the jquery is working.</p>
  
  <p>I am creating an e-commerce with add to cart functionality but when I click on add to cart the products name is not added to the cart. Although the button changes, meaning the json is working but the selection is not working.</p>
  
  <p>add produce in cart (manage_cart.php)</p>
  
  <pre><code>    if(isset($_POST["product_code"])) {
          foreach($_POST as $key =&gt; $value){
              $product[$key] = filter_var($value, FILTER_SANITIZE_STRING);
          }   
          $statement = $this-&gt;conn-&gt;prepare("SELECT product_name, product_price FROM products WHERE product_code=? LIMIT 1");
          $statement-&gt;bind_param('s', $product['product_code']);
          $statement-&gt;execute();
          $statement-&gt;bind_result($product_name, $product_price);
          while($statement-&gt;fetchAll()){ 
              $product["product_name"] = $product_name;
              $product["product_price"] = $product_price;     
              if(isset($_SESSION["produce"])){ 
                  if(isset($_SESSION["produce"][$product['product_code']])) {             
                      $_SESSION["produce"][$product['product_code']]["product_qty"] = $_SESSION["produce"][$product['product_code']]["product_qty"] + $_POST["product_qty"];              
                  } else {
                      $_SESSION["produce"][$product['product_code']] = $product;
                  }           
              } else {
                  $_SESSION["produce"][$product['product_code']] = $product;
              }   
          }   
          $total_product = count($_SESSION["produce"]);
          die(json_encode(array('produce'=&gt;$total_product)));
      }
  </code></pre>
  
  <p>index.php</p>
  
  <pre><code>     &lt;?php
              $newstoreobj = $storeobj-&gt;select_product();
  
              if(count($newstoreobj)){
                foreach ($newstoreobj as $data) {
                  ?&gt;
                  &lt;form class="product-form"&gt;
                      &lt;div class="col-md-3"&gt;
                          &lt;a href="view_product/product.php?product_id=&lt;?php echo  $data['product_id'] ?&gt;/product&lt;?php echo $data['product_name'].'.html'?&gt;"&gt;
                              &lt;div class="prods"&gt;
                                  &lt;div style="height:250px"&gt;
                                      &lt;img src="upload/&lt;?php echo $data['image1'];?&gt;" class="img-responsive" style="padding:20px;height:100%;width:100%" /&gt;
                                  &lt;/div&gt;
                                  &lt;div&gt;
                                      &lt;p class="text-center" style="color:black; font-weight: bolder;"&gt;&lt;?php echo $data['product_name'];?&gt;&lt;/p&gt;
                                      &lt;p class="text-center" style="color:red;font-weight:bold;font-size:24px"&gt;$&lt;?php echo $data['product_price'];?&gt;.00 &lt;/p&gt;
                                  &lt;/div&gt;
                                  &lt;/a&gt;
                                  &lt;select name="product_qty" style="display: none;"&gt;
                                  &lt;option value="1" selected=""&gt;1&lt;/option&gt;
                                  &lt;option value="2"&gt;2&lt;/option&gt;
                                  &lt;option value="3"&gt;3&lt;/option&gt;
                                  &lt;option value="4"&gt;4&lt;/option&gt;
                                  &lt;option value="5"&gt;5&lt;/option&gt;
                                  &lt;/select&gt;
                                  &lt;div class="buton" style="width:100;"&gt;
  
                                        &lt;input name="product_code" type="hidden" value="&lt;?php echo $data["product_code"];?&gt;"&gt; 
                                      &lt;button type="submit" class="btn btn-block btn-danger"&gt;Add to Cart&lt;/button&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
  
  
                      &lt;/div&gt;
                       &lt;/form&gt;
                      &lt;?php
                  }
              }
              ?&gt;
  
      script.js
  
      // add item to cart
          $(".product-form").submit(function(e){
              var form_data = $(this).serialize();
              var button_content = $(this).find('button[type=submit]');
              button_content.html('Adding...'); 
              $.ajax({
                  url: "manage_cart.php",
                  type: "POST",
                  dataType:"json",
                  data: form_data
              }).done(function(data){         
                  $("#cart-container").html(data.products);
                  button_content.html('Add to Cart');             
              })
              e.preventDefault();
          }); 
  </code></pre>
  
  <p>when I click on the add to cart button, I want the product to be added to the cart. Thanks</p>