有高手没 我的出错了 求教

2013 年 5 月 5 日4040

<html>
<head>
<title>Bob's Auto parts -Order Results</title>
</head>

<body>
<h1>Bob's Auto parts</h1>
<h2>Order Results</h2>
<?php
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
$address = $_POST['address'];
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];

$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
$totalamount = 0.00;

echo "<p>Order processed at".date('H:i, js F Y')."</p>";
echo '<p>Your order is as follows:</p>';
echo "Items ordered: ".$totalqty."<br/>";

if($totalqty == 0)
{
echo "You did not order anything on the previous page!<br/>";
}
else
{
if($tireqty > 0)
{
echo $tireqty." tires<br/>";
}
if($oilqty)
{
echo $oilqty." bottles of oil<br/>";
}
if($sparkqty)
{
echo $sparkqty." spark plugs<br/>";
}
}

define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);

$totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE;
$totalamount = number_format($totalamount, 2, '.', ' ');
echo "<p>Total of order is $".$totalamount."</p>";
echo "<p>Address to ship to is ".$address."</p>";

$outputstring = $date."\t".$tireqty." tires \t".$oilqty." oil\t".$sparkqty." spark plugs\t\$".$totalamount."\t".$address."\n";

@ $fp = fopen("$DOCUMENT_ROOT/../orders/orders.txt", 'ab');

flock($fp, LOCK_EX);

if(!$fp)
{
echo "<p><strong>Yout order could not be processed at this time. Please try again later.</stong></p></body></html>";
exit;
}

fwrite($fp, $outputstring, strlen($outputstring));

flock($fp, LOCK_UN);
fclose($fp);

echo "<p>Order written.</p>";

?>
</body>
</html>

0 0