Need some help with PHP calculator.?

  • Thread starter Thread starter Sander V
  • Start date Start date
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.
 
You need to be running a server that supports PHP. It is a server side scripting language only and cannot run on a client machine unless that machine is also a server.
 
Back
Top