Thanks Richard: I finally got it. I'm *really* rusty 'cos I went
completely code blind and struggled for a day with a silly syntax error!
This works just fine:
<?
if ((!ereg("^[0-9]+[.]?[0-9]*$", $val1))||(!ereg("^[0-9]+[.]?[0-9]*$",
$val2))|| ($calc =="")) {
header("Location: http://localhost/calculate_form.html");
exit;
}
if ($calc == "add") {
$result = $val1 + $val2;
} else if ($calc == "subtract") {
$result = $val1 - $val2;
} else if ($calc == "multiply") {
$result = $val1 * $val2;
} else if ($calc == "divide") {
$result = $val1 / $val2;
}
?>
<HTML>
<HEAD>
<TITLE>Calculation Result</TITLE>
</HEAD>
<BODY>
<P>The result of the calculation is: <? echo "$result"; ?></p>
</BODY>
</HTML>
And, for anyone else, it's a simple (but not for me, as it turned out!)
ellaboration on the code in Julie Meloni's PHP fast&easy book to allow
for error checking if a non-numerical value is entered.
--
******************************************************************************
Marx: "Why do Anarchists only drink herbal tea?"
Proudhon: "Because all proper tea is theft."
******************************************************************************
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]