Reputation: 1850
I've got this switch function that is suppose to get the value of a parameter passed in a query string, and upon it decide the value of the variable:
<?php
switch($_REQUEST['textcolor']){
case "white":
$textcolor = $white;
break;
case "black":
$textcolor = $black;
break;
}
?>
The $_REQUEST
gets it's value from this link:
<a href="index2.php?status=Busy&codigo2=<?php echo $codigo2; ?>&textcolor=white">
and this is the form in which I have a hidden element that;s suppose to show the value, but does not:
<form>
<input type="hidden" value="<?= $textcolor ?>">
</form>
Any ideas why the $textcolor
variable is not showing?
EDIT: Solved, the reason was indeed variable not declared. Thanks!
Upvotes: 0
Views: 209
Reputation: 41050
Add a last case
in the switch
default:
die('textcolor is not '.$black.' or '.$white);
break;
Upvotes: 1
Reputation: 212412
switch($_REQUEST['textcolor']){
case "white":
$textcolor = $white;
break;
case "black":
$textcolor = $black;
break;
}
Where are $white and $black defined?
EDIT
Do:
$white = 'white';
$black = 'black';
switch($_REQUEST['textcolor']){
case "white":
$textcolor = $white;
break;
case "black":
$textcolor = $black;
break;
}
and see what happens
Upvotes: 1