I'm creating a simple BMR calculator that calculates the following formula: BMR = 66 + ( 6.23 x weight in pounds ) + ( 12.7 x height in inches ) - ( 6.8 x age in year ). This code has been borrowed and modified so I'm not completely comfortable with it.
Im curious to as why the '66' is already displayed in answer before I press submit. How can I change my code to not display any values in the answer box until submit is pressed?
The calculator can be found here: http://rgoo.co/calculators/bmr-calculator.php
<?php
if (isset($_POST['agev'])) $agev = $_POST['agev'];
if (isset($_POST['feetv'])) $feetv = $_POST['feetv'];
if (isset($_POST['inchesv'])) $inchesv = $_POST['inchesv'];
if (isset($_POST['weightv'])) $weightv = $_POST['weightv'];
$totalheightv = $inchesv + ($feetv*12);
$answer = 66 + (6.23*$weightv) + (12.7*$totalheightv) - (6.8*$agev);
echo <<<_END
<form method='post' action='/calculators/bmr-calculator.php'>
<table border='0' width='500px' cellpadding='2' cellspacing='1' class="table">
<tr class="calcheading"><td colspan="2"><strong>IIFYM test</strong></td></tr>
<tr class="calcrow"><td>AGE:</td><td align="center"><input type='text' name='agev' value="$agev"/>Years</td></tr>
<tr class="calcrow2"><td>Height:</td><td align="center"><input type='text' name='feetv' value="$feetv"/>Ft</td></tr><td align="center"><input type='text' name='inchesv' value="$inchesv"/>In</td></tr>
<tr class="calcrow"><td>Weight:</td><td align="center"><input type='text' name='valuec' value="$valuec"/>lbs</td></tr>
<tr class="submit"><td colspan="2"><input type='submit' value='Calculate'/></td></tr>
_END;
?>
<tr class="calcrow">
<td>Your BMR is:</td>
<td align="center"><input type="text" value="<?php echo round($answer)?>"></td>
</tr>
</table>
</form>