Brian Gagnon
New member
I have an html form that links to a php page that is supposed to do a calculation but all I get when the calculation button is pressed is a new php page that skips the calculation and tells the user to use their browser's back button. Here is the code. I really need the help.
HTML form
<form action="BG_Calculation.php" method="POST">
Estimated time to complete project in hours: <input name="num1" type="text" /><br>
<input type="submit" value="Calculate"/>
</form>
PHP page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Gagnon Partnership Calculation</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
/*This is the php code that makes the calculation that the form uses
to calculate the cose of the project*/
//Brian Gagnon
# 12/6/2010
$num1 = $_POST['num1'];
$num2 = 140;
$submit = isset($_POST['submit']);
if($submit) {
if(is_numeric($num1))
{
$a = $num1 * $num2;
echo "The cost of the project is " . $a;
}
else
{
$a = "Invalid number.";
echo $a;
}
}
echo "Use your browser's back button to return to the last page";
?>
</body>
</html>
HTML form
<form action="BG_Calculation.php" method="POST">
Estimated time to complete project in hours: <input name="num1" type="text" /><br>
<input type="submit" value="Calculate"/>
</form>
PHP page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Gagnon Partnership Calculation</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
/*This is the php code that makes the calculation that the form uses
to calculate the cose of the project*/
//Brian Gagnon
# 12/6/2010
$num1 = $_POST['num1'];
$num2 = 140;
$submit = isset($_POST['submit']);
if($submit) {
if(is_numeric($num1))
{
$a = $num1 * $num2;
echo "The cost of the project is " . $a;
}
else
{
$a = "Invalid number.";
echo $a;
}
}
echo "Use your browser's back button to return to the last page";
?>
</body>
</html>