我正在关注 Luke Welling 和 Laura thompson 关于 PHP-MYSQL Web 开发的书,我在 html 中有以下代码:
<form action="processorder.php" method=post>
<table border=0>
<tr bgcolor=#cccccc>
<td width=150>Item</td>
<td width=15>Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3"
maxlength="3"></td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3"></td>
</tr>
<tr>
<td>Spark Plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3"
maxlength="3"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit Order"></td>
</tr>
</table>
</form>
<tr>
<td>How did you find Bob's</td>
<td><select name="find">
<option value = "a">I'm a regular customer
<option value = "b">TV advertising
<option value = "c">Phone directory
<option value = "d">Word of mouth
</select>
</td>
</tr>
和 php 中的这段代码:
<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results
<?php
//create short variable names
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
echo '<p>Order processed at ';
echo date('H:i, jS F');
echo '</p>';
echo '<p>Your order is as follows: </p>';
echo "$tireqty tires<br />";
echo "$oilqty bottles of oil<br />";
echo "$sparkqty spark plugs<br />";
$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo 'Items ordered: '.$totalqty.'<br />';
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;
echo 'Subtotal: $'.number_format($totalamount,3).'<br />';
$taxrate = 0.10; // local sales tax is 10%
$totalamount = $totalamount * (1 + $taxrate);
echo 'Total including tax: $'.number_format($totalamount,2).'<br />'
switch($find)
{
case "a":
echo "<p>Regular customer.</p>";
break;
case "b" :
echo "<p>Customer referred by TV advert.</p>";
break;
case "c" :
echo "<p>Customer referred by phone directory.</p>";
break;
case "d" :
echo "<p>Customer referred by word of mouth.</p>";
break;
default :
echo "<p>We do not know how this customer found us.</p>";
break;
}
?>
</h2>
</body>
</html>
按下提交按钮时出现服务器错误。开关块导致问题。我正在使用 PhP 5.3.10。谁能指出我的问题?提前致谢。