When the form is submitted the following error:
PHP Notice: Undefined offset: 1 in E:\php\learning2\increase.php on line 10
PHP Notice: Undefined index: quantity in E:\php\learning2\increase.php on line 10
Form:
<form action="increase.php" method="post">
<input type="hidden" name="productId" value="1">
<input type="number" name="productQuantity" value="1">
<input type="submit" name="submit" value="Add to basket">
</form>
increase.php
session_start();
if (isset($_POST['submit'])) {
$productId = $_REQUEST['productId'];
$productQuantity = $_REQUEST['productQuantity'];
$_SESSION['cart'][$productId]['quantity'] += $productQuantity;
header('Location: http://localhost:8000/');
}
How can it be solved?