I am working on a shopping cart in PHP and I seem to be getting this error "Notice: Undefined index:" in all sorts of places. The error refers to the similar bit of coding in different places. For example I have a piece of coding that calculates a package price with the months a user decides to subscribe. I have the following variables where the errors refers to:
$month = $_POST['month']; $op = $_POST['op']; The $month variable is the number the user inputs in a form, and the $op variable is different packages whose value are stored in a vriable that a user selects from radio buttons on the form.
I hope that is clear in some way.
Thank You
EDIT: Sorry forgot to mention that they do go away when the user submits the data. But when they first come to the page it displays this error. How I can get rid of it so it doesnt display it?
--
This is the code:
<?php $pack_1 = 3; $pack_2 = 6; $pack_3 = 9; $pack_4 = 12; $month = $_POST['month']; $op = $_POST['op']; $action = $_GET['action']; if ( $op == "Adopter" ) { $answer = $pack_1 * $month; } if ( $op == "Defender" ) { $answer = $pack_2 * $month; } if ( $op == "Protector" ) { $answer = $pack_3 * $month; } if ( $op == "Guardian" ) { $answer = $pack_4 * $month; } switch($action) { case "adds": $_SESSION['cart'][$answer][$op]; break; } ?>