Advertisement
mariusqw

Untitled

May 12th, 2020
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST['submitForm'])) {
  4. $personWeight = $_POST['personWeight'];
  5. $personHeight = $_POST['personHeight'];
  6.  
  7. if($personWeight > 300 | $personWeight < 20) {
  8. header('Location: index.php?error=weightError');
  9. die();
  10. } else if($personHeight > 3 || $personHeight < 1) {
  11. header('Location: index.php?error=heightError');
  12. die();
  13. }
  14.  
  15. echo "Apskaičiuotas KMI: " . calculateKmi($personWeight, $personHeight);
  16. } else {
  17. header('Location: index.php');
  18. die();
  19. }
  20.  
  21. function calculateKmi($personWeight, $personHeight) {
  22. return $personWeight / ($personHeight * $personHeight);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement