Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submitForm'])) {
- $personWeight = $_POST['personWeight'];
- $personHeight = $_POST['personHeight'];
- if($personWeight > 300 | $personWeight < 20) {
- header('Location: index.php?error=weightError');
- die();
- } else if($personHeight > 3 || $personHeight < 1) {
- header('Location: index.php?error=heightError');
- die();
- }
- echo "Apskaičiuotas KMI: " . calculateKmi($personWeight, $personHeight);
- } else {
- header('Location: index.php');
- die();
- }
- function calculateKmi($personWeight, $personHeight) {
- return $personWeight / ($personHeight * $personHeight);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement