You are referencing the variables properly on the first if line, but then you're calling $var1 and $var2 w/o using $_GET. Add that or do this:
$var1 = $_GET['var1']; $var2 = $_GET['var2']; You may also want to use !isset($varname) instead of checking to see if the variables are equal to a space char (" "). -Dash "I have made mistakes but I have never made the mistake of claiming that I have never made one." -- James Gordon Bennett On Wed, 29 Jan 2003, Wade wrote: > 01292003 1540 CST > > When I run this script I get the html at the end but no $result. If the > result is run on the same page as the output, there shouldnt be anything > variable wise stopping this from running, right? > > Wade > > <?php > if (($_POST["val1"] == " ") || ($_POST["val2"] == " ") || > ($_POST["calc"] == " ")) > { > header("Location: http://localhost/Learning PHP/PHP Fast & > Easy/Ch_6/calculate_form.html"); > exit; > } > > if ($_POST["calc"] == "add") > { > $result = $val1 + $val2; > } > > else if ($_POST["calc"] == "subtract") > { > $result = $val1 - $val2; > } > > else if ($_POST["calc"] == "multiply") > { > $result = $val1 * $val2; > } > > else if ($_POST["calc"] == "divide") > { > $result = $val1 / $val2; > } > > ?> > > <html> > <head> > <title>Calculation Result</title> > <head> > > <body> > <p>The result of the calculation is: <?php "$result"; ?></p> > </body> > </html> > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php