Hello everyone,
I created a form for taking an order lunch.Everything works fine only i get an error on my php file on the array section.
Notice: Undefined index: drink in lunch.php
I don't see i have missed anything, but i hope someone might be able to spot my mistake.Please advice!
Thanks
<head>
<meta charset = "utf-8"/>
<title>LUNCH ORDER</title>
<h1>WELCOME</h1>
</head>
<?php
$drinks = $_POST['drink'];
$drink1 = $drinks[0];
$drink2 = $drinks[1];
$first_name = $_POST['first_name'];
if(isset($_POST['first_name'])){
$first_name =$_POST['first_name'];
echo $first_name;
}else{
$first_name = "unknown";
echo $first_name;
}
$lunch =$_POST['lunch'];
if(isset($_POST['lunch'])){
$lunch = $_POST['lunch'];
echo '<br>'."You ordered".'<br>'.$lunch;
}else{
$lunch = "unknown";
echo $lunch;
}
if(isset($_POST['drink'])){
$drinks = $_POST['drink'];
foreach($drinks as $key =>$value){
echo $key. ' = ' .$value. '<br>';
}
}else{
echo '<br>'.'No drink selected.';
}
?>
</html>