Add products without refresh

-3

Good morning, adding a product to the cart every time you upgrade your browser increases the product by +1. how to prevent this? so you can add it:

    //adiciona produto

    if(isset($_GET['acao'])){
      $id = intval($_GET['id']);
          if(!isset($_SESSION['shop'][$id])){
             $_SESSION['shop'][$id] = 1;
          }else{
             $_SESSION['shop'][$id] += 1;
          }
       }
    
asked by anonymous 27.01.2016 / 12:15

1 answer

-2
!isset($_SESSION['shop'][$id])

Try to replace the isset with empty, like this:

!empty($_SESSION['shop'][$id])

You can also use php functions to manipulate array like in_array , array_key_exists and etc ... Maybe solve.

    
28.01.2016 / 02:32