I have the same book, and after spending ages trying to see if I made a type, google brought me here and ended my frustrations. The amazon reviews for this book are awful, but we're using it in class, and although there are many errors the structure of the book is pretty good, and just like you, I ended up learning something because of the errors.
My solution ended up working like this:
<?php
if ( ($_POST['val1']=="") || ($_POST['val2']=="") || ($_POST['calc']=="") ) {
header("Location:calcform.php");
exit;
}
if ($_POST['calc'] == "add") {
$result = $_POST['val1'] + $_POST['val2'];
}
else if ($_POST['calc'] == "subtract") {
$result = $_POST['val1'] - $_POST['val2'];
}
else if ($_POST['calc'] == "multiply") {
$result = $_POST['val1'] * $_POST['val2'];
}
else if ($_POST['calc'] == "divide") {
$result = $_POST['val1'] / $_POST['val2'];
}
?>
<!DOCTYPE html>
<head>
<title>Calculation Result</title>
</head>
<body>
<p>The result of the calculation is <?php echo "$result"; ?>!</p>
</body>
</html>