# How to Calculate BMI(Body Mass Index) Using PHP With HTML Form?

BMI Calculate Create With PHP: You can easily create bmi calculator using php code with html from.

Hello friends today i will tell you through this article how you can create bmi calculator using php.I will try to understand you step to step. so let’s go.

First of all, you create a form using the html code of the bmi calculator.And then add the php code of the bmi calculator to this page or create bmi.php file then add php code og the bmi calculator.As explained below.

BMI Calculator Create by PHP, Create BMI Calculator Using PHP, html and css, BMI CalculatE with html form and PHP

Overview

Step 1:- Create BMI Calculator HTML Form(bmi-calculate.html).
Step 2:- Create BMI Calculator PHP Code(bmi.php).

Step 1:- Create BMI Calculator HTML Form(bmi-calculate.html).

bmi-calculate.html

`<!DOCTYPE html><html><head><title>How to Calculate BMI(Body Mass Index) Using PHP With HTML Form?</title></head><body><form method="GET" action="bmi.php">Mass in kilogram (kg):-<input type="text" name="mass"><br> Height in meter (m):-<input type="text" name="height"><br><input type="submit" name="submit" value="submit"></form></body></html>`

Step 2:- Create BMI Calculator PHP Code(bmi.php).

bmi.php

`<?php if (\$_GET['submit']) { \$mass = \$_GET['mass'];\$height = \$_GET['height'];function bmi(\$mass,\$height) {\$bmi = \$mass/(\$height*\$height);return \$bmi;} \$bmi = bmi(\$mass,\$height);if (\$bmi <= 18.5) {\$output = "Under Weight";} else if (\$bmi > 18.5 AND \$bmi<=24.9 ) {\$output = "Normal Weight";} else if (\$bmi > 24.9 AND \$bmi<=29.9) {\$output = "Over Weight";} else if (\$bmi > 30.0) {\$output = "OBESE";}echo "Your BMI value is " . \$bmi . " and you are : "; echo "\$output";}?>`