Form using function calculate BMI and display different comment. Fatal error and not displaying correctly
<p>I am creating a form that uses function to calc BMI. Two questions.</p>

<ol>
<li><p>the comment (underweight/normal weight/...) should output differently depending on the BMI calculated, however no matter what value BMI is, it always outputs UNDERWEIGHT. What do I need to do so that it works?</p></li>
<li><p>"Fatal error: Call to undefined function bmi() in..." a fatal error is displayed although the function works. Could anyone teach me how to get rid of this error? Thank you so much.</p>

<pre><code>&lt;form name="bmi" method="GET" action="test.php"&gt;
  Mass in kilogram (kg):
  &lt;input type="text" name="mass" id="mass" size="15"&gt;
  &lt;br&gt; 

  Height in meter (m):
  &lt;input type="text" name="height" id="height" size="15"&gt;
  &lt;br&gt;

  &lt;input type="submit" name="submit" id="submit" value="submit"&gt;
&lt;/form&gt;

&lt;?php
if ($_GET['submit']) { 
  $mass = $_GET['mass'];
  $height = $_GET['height'];

  function bmi($mass,$height) {
    $bmi = $mass/($height*$height);
    return $bmi;
  } 

  if ($bmi &lt;= 18.5) {
    $output = "UNDERWEIGHT";

  } else if ($bmi &gt; 18.5 AND $bmi&lt;=24.9 ) {
    $output = "NORMAL WEIGHT";

  } else if ($bmi &gt; 24.9 AND $num&lt;=29.9) {
    $output = "OVERWEIGHT";

  } else if ($bmi &gt; 30.0) {
    $output = "OBESE";
  }
}
echo "Your BMI value is  " . bmi($mass,$height). "  and you are : "; 
echo "$output";
?&gt;
</code></pre></li>
</ol>