orderform.html
processorder.php
<?php
$tireqty=$_POST['tireqty'];
$oilqty=$_POST['oilqty'];
$sparkqty=$_POST['sparkqty'];
$address=$_POST['address'];
$document_root=$_SERVER['DOCUMENT_ROOT'];
?>
<html>
<head>
<title>
Bob's Auto Parts-Order Results
</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
$date=date('H:i,jS F');
echo '<p>Order processed at';
echo $date;
echo '</P>';
echo '<P>Your order is as follows:</P>';
$totalqty=0;
$totalqty=$tireqty+$oilqty+$sparkqty;
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>0)
echo $oilqty.'oil<br>';
if($sparkqty>0)
echo $sparkqty.'spark<br>';
}
$totalamount=0.00;
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/order/data/order.txt",'ab');
if(!$fp)
{
echo '<P><strong>Your order could not be processed at this time.'
.'Please try again later.</strong></P></body></html>';
exit;
}
fwrite($fp,$outputstring,strlen($outputstring));
fclose($fp);
echo '<P>Order Written.</P>';
?>
</body>
</html>
测试页面 http://www.waigua.biz/orde...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml...
<html xmlns="http://www.w3.org/1999/xht...
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Bob's basic order form</title>
</head>
<body>
<form action="processorder.php" method="post">
<table>
<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>Address</td>
<td align="center"><input type="text" name="address" size="20" ></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="提交"/></td>
</tr>
</table>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xht...
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Bob's basic order form</title>
</head>
<body>
<form action="processorder.php" method="post">
<table>
<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>Address</td>
<td align="center"><input type="text" name="address" size="20" ></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="提交"/></td>
</tr>
</table>
</form>
</body>
</html>
processorder.php
<?php
$tireqty=$_POST['tireqty'];
$oilqty=$_POST['oilqty'];
$sparkqty=$_POST['sparkqty'];
$address=$_POST['address'];
$document_root=$_SERVER['DOCUMENT_ROOT'];
?>
<html>
<head>
<title>
Bob's Auto Parts-Order Results
</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
$date=date('H:i,jS F');
echo '<p>Order processed at';
echo $date;
echo '</P>';
echo '<P>Your order is as follows:</P>';
$totalqty=0;
$totalqty=$tireqty+$oilqty+$sparkqty;
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>0)
echo $oilqty.'oil<br>';
if($sparkqty>0)
echo $sparkqty.'spark<br>';
}
$totalamount=0.00;
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/order/data/order.txt",'ab');
if(!$fp)
{
echo '<P><strong>Your order could not be processed at this time.'
.'Please try again later.</strong></P></body></html>';
exit;
}
fwrite($fp,$outputstring,strlen($outputstring));
fclose($fp);
echo '<P>Order Written.</P>';
?>
</body>
</html>
测试页面 http://www.waigua.biz/orde...
军训,高一
哎呀呀
2007/11/06 14:54 | by






