PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Notice: Undefined index: buttonClicked in /home/erggnfr/public_html/web/AW16/checkout.php on line 259
Notice: Undefined index: buttonClicked in /home/erggnfr/public_html/web/AW16/checkout.php on line 288
$buttonClicked = isset($_POST['buttonClicked']) ? $_POST['buttonClicked'] : 0; // you can set default value instead of 0
if ($buttonClicked == 1)
....
.....
Last edited by requinix on Fri Sep 23, 2016 6:39 am, edited 1 time in total.
Reason:courtesy typo correction
$buttonClicked = isset($_POST['buttonClicked']) ? $_POST['buttonClicked'] : 0; // you can set default value instead of 0
if ($buttonClicked == 1)
....
.....
where to i put this in context the the previous script?
Before your is_numeric checks. This first checks if it exists and, if not, initializes it to 0. You could even cast it to an int and remove the is_numeric checks altogether, depending on your requirements.
if (isset($_POST['buttonClicked']) {
switch($_POST['buttonClicked']) {
case '1':
// code if 1
break;
case '2':
// code if 2
break;
default:
// invalid value error
}
} else {
// not set error
}