Problem: Notice: Undefined index: ID in C:\wamp64\www\index1.php on line 14
I have been finding solutions for the problem, so far none could solve my problem. I use mySQL database also, but the only problem I am having is the undefined index and all the variables are named exactly as how it is in the MySQL table. Could someone help be solve this problem. Below is the code
if (isset($_POST['add_to_cart'])) {
if (isset($_SESSION['cart'])) {
$session_array_id = array_column($_SESSION['cart'], "ID");
if (!in_array($_GET['ID'], $session_array_id)) {
$session_array = array(
'ID' => $_GET['ID'],
"Name" => $_POST['Name'],
"Price" => $_POST['Price'],
"quantity" => $_POST['quantity']
);
$_SESSION['cart'][] = $session_array;
}
}else{
$session_array = array(
'ID' => $_GET['ID'],
"Name" => $_POST['Name'],
"Price" => $_POST['Price'],
"quantity" => $_POST['quantity']
);
$_SESSION['cart'][] = $session_array;
}
}