# How to Create Simple Calorie Calculator Using PHP

Hello guys, This tutorial is all about How to Create Simple Calorie Calculator Using PHP.

Determining our calorie will help us have a balanced diet and Calorie are essential for human health.

So let’s get started:

First create a class and name it “index.php” and add this code:

``````<html>
<body>
<center>
<form method="post">
Gender:
<Select name="gender" ><br>
<option>Male</option>
<option>Female</option>
</select><br><br>
Age:
<input name="age" type="text"> yrs.<br><br>
Weight:
<input name="weight" type="text">kgs.<br><br>
Height:
<input name="height" type="text">cm.<br><br>
<br><input type="Submit" value="Calculate">

<?php
\$age=\$_POST['age'];
\$weight=\$_POST['weight'];
\$height = \$_POST['height'];
\$calories="0.0215183";
\$gender=\$_POST['gender'];

switch (\$gender){
case 'Female':
\$gender= 655 + (9.6 * \$weight ) + (1.8 * \$height) - (4.7 * \$age);
echo "<p>Your estimated daily metabolic rate is \$gender </p>";
echo "<p>This means that you need rouhgly \$gender calories a day to maintain your current weight.</p>";

break;
case 'Male':
\$gender=66 + (13.7 *\$weight) + (5 * \$height) - (6.8 * \$age);
echo "<p>Your estimated daily metabolic rate is \$gender </p>";
echo "<p>This means that you need rouhgly \$gender calories a day to maintain your current weight.</p>";

}
?>

</form>
</center>
</body>
</html>``````

Simple as that! Go and test the program now.

Here’s the output:

If you have any comments or suggestions about How to Create Simple Calorie Calculator Using PHP Please message us directly.