Every time a POST value is not equal to the list of values set in an array will return: Undefined Index error, I made an if statement but is not working.
Here\'s the
I'm a bit confused by your code. It looks like your array has the same key and value, so:
$products['saucepan'] = 'saucepan'
Perhaps you are trying to do this, which will check whether the product exists in the products array:
if(isset($_POST['product']) && array_key_exists($_POST['product'], $products))
{
// do stuff
}
else
{
echo "This item is not available";
}