0
if($_REQUEST['command']=='add' && $_REQUEST['productid']>0){
        $pid=$_REQUEST['productid'];
        addtocart($pid,1);
        header("location:shoppingcart.php");
        exit();
    }

Notice: Undefined index: command in C:\wamp64\www\WSMshop\products.php on line 5 and that's the error, i do what i know can fix it, but nothing happen. Please help me. im still newbie in this. TIA

4n93l0
  • 1
  • 1

1 Answers1

-2

Since too little code is provided - my suggestion is to simply make additional check whether the 'command' is being submit by changing the if statement to:

if(isset($_REQUEST['command']) && $_REQUEST['command']=='add' && $_REQUEST['productid']>0){

Cheers!

Barmar
  • 741,623
  • 53
  • 500
  • 612
Berckoff
  • 31
  • 1
  • 2
  • Thanks ^_^, i'll try. – 4n93l0 Oct 03 '17 at 08:44
  • if(isset($_REQUEST['command']) && $_REQUEST['command']=='delete' && $_REQUEST['pid']>0){ remove_product($_REQUEST['pid']); } else if(isset($_REQUEST['command']) && $_REQUEST=='clear'){ unset($_SESSION['cart']); } else if($_REQUEST['command']=='update'){ $max=count($_SESSION['cart']); //my error is here for($i=0;$i<$max;$i++){ $pid=$_SESSION['cart'][$i]['productid']; $q=intval($_REQUEST['product'.$pid]); if($q>0 && $q<=999){ $_SESSION['cart'][$i]['qty']=$q; } else{ $msg='Some proudcts not updated!, quantity must be a number between 1 and 999'; – 4n93l0 Oct 03 '17 at 09:51