<?php


$tinggi=$_POST["data1"];
$berat=$_POST["data2"];

$cTinggi=number_format($tinggi/100,2,'.',',');
$bmi=number_format(($berat / ($cTinggi*$cTinggi)),1,'.',',');

//Determine catagories
if ($bmi <=18.5)
{
$status="underweight";
$hover=1;
}
elseif ($bmi >18.5 && $bmi <=24.9)
{
$status="normal weight";
$hover=2;
}
elseif ($bmi >24.9 && $bmi <=29.9)
{
$status="overweight";
$hover=3;
}
else
{
$status="obesity";
$hover=4;
}


?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Body Mass Index Calculator</title>
<style type="text/css">
<!--
.style5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF; }
.style10 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
-->
</style>
</head>

<body>
<p><strong><u>Your Input:</u></strong><br>
  Height = <?php echo $tinggi; ?> cm
  <br>
  Weight = <?php echo $berat; ?> Kg</p>
<p><u><strong><u>Result</u></strong><br>
</u><br>
Your BMI index is <strong><?php echo $bmi; ?></strong>, indicating your weight is in the <strong><?php echo $status; ?></strong> category for adults of your height.</p>
<table width="278" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="152" bgcolor="#0066FF"><span class="style5">Body Type </span></td>
    <td width="126" bgcolor="#0066FF"><span class="style5">BMI Index </span></td>
  </tr>
  <tr <?php if ($hover==1) echo "bgcolor='red'"; ?>>
    <td><span class="style10">Underweight</span></td>
    <td><span class="style10">&lt;=18.5</span></td>
  </tr>
  <tr <?php if ($hover==2) echo "bgcolor='red'"; ?>>
    <td><span class="style10">Normal</span></td>
    <td><span class="style10">18.6-24.9</span></td>
  </tr>
  <tr <?php if ($hover==3) echo "bgcolor='red'"; ?>>
    <td><span class="style10">Overweight</span></td>
    <td><span class="style10">25-29.9</span></td>
  </tr>
  <tr <?php if ($hover==4) echo "bgcolor='red'"; ?>>
    <td><span class="style10">Obesity</span></td>
    <td><span class="style10">&gt;=30</span></td>
  </tr>
</table>
<p><a href="index.php">[Click Here to Try Again] </a></p>
</body>
</html>
