Advertisement
melody45

BMI calculator

Mar 25th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. <?php include 'header.php'; ?>
  2.  
  3. <script language="JavaScript">
  4. <!--
  5. function calculateBmi() {
  6. var weight = document.bmiForm.weight.value
  7. var height = document.bmiForm.height.value
  8. if(weight > 0 && height > 0){
  9. var finalBmi = weight/(height/100*height/100)
  10. document.bmiForm.bmi.value = finalBmi
  11. if(finalBmi < 18.5){
  12. document.bmiForm.meaning.value = "You are too thin."
  13. }
  14. if(finalBmi > 18.5 && finalBmi < 25){
  15. document.bmiForm.meaning.value = "Your are healthy."
  16. }
  17. if(finalBmi > 25){
  18. document.bmiForm.meaning.value = "You have overweight."
  19. }
  20. }
  21. else{
  22. alert("Please Fill in everything correctly")
  23. }
  24. }
  25. //-->
  26. </script>
  27. <style>
  28. td {
  29. height:20px;
  30. }
  31. </style>
  32. <?php if(!isset($_SESSION['u_name']) && empty($_SESSION['u_name'])){
  33.  
  34. echo '<div class="bigbox">
  35. <div class="heading" style="margin-top:50px;">Sorry ! you are not logged in. | Login to view this Page</div>
  36. <hr></div>';
  37. }else {
  38.  
  39. echo'
  40. <div class="bigbox">
  41. <div class="heading" style="margin-top:50px;">Calculate Your Body Mass Index (BMI) | Calculator is Below</div>
  42. <hr>
  43. <table border="0" style="width:650px;margin:0 auto;border:2px solid #F25822;
  44. border-radius:5px;padding-top:15px;padding-left:5px;padding-bottom:15px;padding-right:5px;box-shadow:0px 0px 5px 5px grey;margin-top:40px;">
  45. <tr>
  46. <form name="bmiForm">
  47. <td>Your Weight(kg):</td><td><input type="text" name="weight" placeholder="Your Weight (Kg)"></td>
  48.  
  49. <td>Your Height(cm): </td><td><input type="text" name="height" placeholder="Your Height (CM)"></td></tr>
  50. <tr><td colspan="4"><hr style="display:none;"></td></tr>
  51. <tr><td colspan="4" align="right"><input type="button" value="Calculate BMI" style="width:200px;margin-right:30px;" onClick="calculateBmi()" class="button"></td></tr>
  52. <tr><td colspan="4"><hr ></td></tr>
  53. <tr><td>Your BMI:</td><td colspan="3"><input type="text" readonly style="border:none;font-weight:bold;" size="65" name="bmi" placeholder="Your BMI Calculations will show here"></td></tr>
  54. <tr><td>Remarks: </td><td colspan="3"><input type="text" readonly style="border:none;font-weight:bold;" size="65" name="meaning" placeholder="Remarks"></td></tr>
  55. <tr><td colspan="4"><hr style="display:none;"></td></tr>
  56. <tr><td colspan="4" align="right"><input type="reset" value="Reset" style="width:200px;margin-right:30px;" class="button" /></td></tr>
  57. </form>
  58. </table>
  59. </div>';}
  60.  
  61. ?>
  62. <?php include 'footer.php'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement