S
Sander V
Guest
Hi folks, I just switched from C++ to PHP and now I'm making a BMI calculator.
The form on one page is as follows:
<form method="post" action=calculator.php>
<b>Weight in kilograms:</b><input type="text" size="12" name="W"><br />
<b>Length in M.CM format:</b><input type="text" size="12" name="L"><br />
<input type="submit" value="Calculate BMI">
</form>
And then the PHP calculator part, which is very basic atm as I'm just trying to find out if I can get some output of the variables, is this:
<?php
$W = $_POST["W"];
$L = $_POST["L"];
$B;
if (is_numeric($W) && is_numeric($L))
{
$B = $W * ($L * $L);
echo ("Your BMI is : $B");
}
?>
However, whenever I press submit on the form, I go to calculator.php but only see my bare, naked layout.
What am I doing wrong? Thanks in advance.
I am running on a PHP enabled server.
The form on one page is as follows:
<form method="post" action=calculator.php>
<b>Weight in kilograms:</b><input type="text" size="12" name="W"><br />
<b>Length in M.CM format:</b><input type="text" size="12" name="L"><br />
<input type="submit" value="Calculate BMI">
</form>
And then the PHP calculator part, which is very basic atm as I'm just trying to find out if I can get some output of the variables, is this:
<?php
$W = $_POST["W"];
$L = $_POST["L"];
$B;
if (is_numeric($W) && is_numeric($L))
{
$B = $W * ($L * $L);
echo ("Your BMI is : $B");
}
?>
However, whenever I press submit on the form, I go to calculator.php but only see my bare, naked layout.
What am I doing wrong? Thanks in advance.
I am running on a PHP enabled server.