Untitled
unknown
plain_text
2 years ago
2.2 kB
1
Indexable
Never
<?php $msg = ""; $result = ""; $type = ""; if(!empty($_GET['height']) && !empty($_GET['weight'])){ $height = (float) ($_GET['height'] / 100); $weight = (float) $_GET['weight']; $result = number_format($weight / ($height*$height), 2, '.', ''); } if($result != 0){ if($result < 16){ $type = 'Severe thinnes'; }else if($result >= 16 && $result < 17){ $type = 'Moderate thinnes'; }else if($result >= 17 && $result < 18.5){ $type = 'Mild thinnes'; }else if($result >= 18.5 and $result < 25){ $type = 'Normal'; }else if($result >= 25 && $result < 30){ $type = 'Overweight'; }else if($result >= 30 && $result < 35){ $type = 'Obese Class I'; }else if($result >= 35 && $result < 40){ $type = 'Obesse Class II'; }else{ $type = 'Obese Class III'; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="style.css"> <title>Body Mass Index</title> </head> <body> <form id="login-form" method="GET"> <div class="mb-1"> <h2><?=$msg?></h2> </div> <div class="mb-1"> <label class="form-label" for="height">Height</label> <input class="form-control" type="text" name="height" id="pass" placeholder="Enter your height" required> </div> <div class="mb-1"> <label class="form-label" for="weight">Weight</label> <input class="form-control" type="text" name="weight" id="pass" placeholder="Enter your weight" required> </div> <div class="mb-1"> <input class="form-control" type="submit" value="Calculate"> </div> <div class="mb-1"> <h2><?=$result?></h2> <h2><?=$type?></h2> </div> </form> </body> </html>