title: i want to increase cart quantity php every time add to cart is clicked. I checked few provided solutions but none of them worked
body: <pre><code>&lt;?php
  session_start();
  if (isset($_GET) &amp; !empty($_GET)) {
      $id = $_GET['id'];
      $url = $_GET['sourceurl'];
  if (isset($_GET['quant']) &amp; !empty($_GET['quant'])) {
      $quant = $_GET['quant'];
  } else {
      $quant = 1;
  }
  $_SESSION['cart'][$id] = array("quantity" =&gt; $quant);
  //header('location:' . $url);
  //header('location:index.php?message=1');
  } else {
  //header('location:' . $url);
  }
  echo "&lt;pre&gt;";
  print_r($_SESSION['cart']);
  echo "&lt;/pre&gt;";
  </code></pre>
  
  <p>I have common php page addtocart.php to add product directly to cart from homepage and also from single.php where user can add quantity. If quantity is not given(i.e adding to cart from index page) quantity is directly set to 1. Here I want to increase quanity every time user clicks on addtocart. Above is the code of addtocart.php</p>