Your code worked on my local machine with some sample data… I tried replicating the data as if everything was a string and it worked. But I suggest you type juggle and deal with appropriate data types.
This worked for me as well:
// $weight = (float) $_POST["txtWeight"];
// $height = (float) $_POST["txtHeight"];
// $unit = (string) $_POST["optUnit"];
// Our Sample Data
$weight = (float) '185.33';
$height = (float) '5.11';
$unit = (string) ' ';
$message = ' ';
switch ($unit) {
case 'metric':
$bmiCalc = $weight/($height*$height);
echo $message = 'Metric BMI: ' . $bmiCalc;
break;
default:
$bmiCalc = ($weight * 703)/($height * $height);
echo $message = 'Imperial BMI: ' . $bmiCalc;
break;
}