I want a default value and get rid off the notice. Below is my code
<?php
$color = $_POST["color"]; //initialize variable
if (!isset($color)){ // if nothing selected set default to Blue
$color = 'Blue';
}
echo $color;
?>
So when I run the code and nothing is selected and the blue value (as it is set for default) does show up but the notice message also shows up. I want to get rid of the notice message completely. I have tried array_key_exists as well. Still can not get rid of the notice.
below is the notice I'm getting. Notice: Undefined index: color in C:\xampp\htdocs\test3\Assignment_1_Q2.php on line 17
Thank you in advance.