见图
5 个解决方案
#1
木有人回答么
#2
源代码如下,是两个文件,一个提交数据,一个处理数据。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<style>
dl,dt,dd {margin: 0;}
</style>
</head>
<body>
<form action="processorder.php" method="post">
<div>
<dl>
<dt>Item</dt>
<dd>Quantity</dd>
<dt>Tires</dt>
<dd><input type="text" name="tireqty"/></dd>
<dt>oil</dt>
<dd><input type="text" name="oilqty"/></dd>
<dt>Spark plugs</dt>
<dd><input type="text" name="sparkqty"/></dd>
<dt>Shop Address</dt>
<dd><input type="text" name="address"/></dd>
<input type="submit" value="Submit Orders" />
</dl>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>Order Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
</head>
<body>
<h1>Bob's auto Parts</h1>
<h2>Order Results</h2>
<?php
echo "<p>Order Precessed at ";
echo date('H:i,jS F');
echo "</p>";
?>
<?php
$totalqty = 0;
print_r($_POST);
echo "<br />";
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty= $_POST['sparkqty'];
$address = $_POST['address'];
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$totalqty = $tireqty+$oilqty+$sparkqty;
$date = date('H:i,jS F Y');
echo "Item Ordered: $totalqty<br />";
if ($totalqty==0) {
echo "You did not order anything on the Bob's site!";
} else {
if ($tireqty>0) {
echo $tireqty."tireqty<br />";
}
if ($oilqty>0){
echo $oilqty."oilqty<br />";
}
if ($sparkqty>0) {
echo $sparkqty."sparkqty<br />";
}
}
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OLIPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty*TIREPRICE
+$oilqty*OLIPRICE
+$sparkqty*SPARKPRICE;
$totalamount = number_format($totalamount,2,'.','');
echo "<p>Totalamount is $".$totalamount."</p>";
$tax_rate = 0.1;
$totalamount = $totalamount*(1+$tax_rate);
echo "Total including tax:$".$totalamount."<br />";
$putstrings =$date."\t".$tireqty." tires\t".$oilqty." oil\t".$sparkqty." spark plugs\t"."Totalamount $".$totalamount."\t"."Address ".$address."\r\n";
print_r($DOCUMENT_ROOT);
@$fp = fopen("$DOCUMENT_ROOT/../orders/order.txt", 'ab');
flock($fp, LOCK_EX);
if (!$fp) {
echo "<p>your order is not processed at this time.
Please try again later.</p></body></html>";
exit;
}
fwrite($fp, $putstrings,strlen($putstrings));
flock($fp, LOCK_UN);
fclose($fp);
echo "Order Written!";
?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<style>
dl,dt,dd {margin: 0;}
</style>
</head>
<body>
<form action="processorder.php" method="post">
<div>
<dl>
<dt>Item</dt>
<dd>Quantity</dd>
<dt>Tires</dt>
<dd><input type="text" name="tireqty"/></dd>
<dt>oil</dt>
<dd><input type="text" name="oilqty"/></dd>
<dt>Spark plugs</dt>
<dd><input type="text" name="sparkqty"/></dd>
<dt>Shop Address</dt>
<dd><input type="text" name="address"/></dd>
<input type="submit" value="Submit Orders" />
</dl>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>Order Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
</head>
<body>
<h1>Bob's auto Parts</h1>
<h2>Order Results</h2>
<?php
echo "<p>Order Precessed at ";
echo date('H:i,jS F');
echo "</p>";
?>
<?php
$totalqty = 0;
print_r($_POST);
echo "<br />";
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty= $_POST['sparkqty'];
$address = $_POST['address'];
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$totalqty = $tireqty+$oilqty+$sparkqty;
$date = date('H:i,jS F Y');
echo "Item Ordered: $totalqty<br />";
if ($totalqty==0) {
echo "You did not order anything on the Bob's site!";
} else {
if ($tireqty>0) {
echo $tireqty."tireqty<br />";
}
if ($oilqty>0){
echo $oilqty."oilqty<br />";
}
if ($sparkqty>0) {
echo $sparkqty."sparkqty<br />";
}
}
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OLIPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty*TIREPRICE
+$oilqty*OLIPRICE
+$sparkqty*SPARKPRICE;
$totalamount = number_format($totalamount,2,'.','');
echo "<p>Totalamount is $".$totalamount."</p>";
$tax_rate = 0.1;
$totalamount = $totalamount*(1+$tax_rate);
echo "Total including tax:$".$totalamount."<br />";
$putstrings =$date."\t".$tireqty." tires\t".$oilqty." oil\t".$sparkqty." spark plugs\t"."Totalamount $".$totalamount."\t"."Address ".$address."\r\n";
print_r($DOCUMENT_ROOT);
@$fp = fopen("$DOCUMENT_ROOT/../orders/order.txt", 'ab');
flock($fp, LOCK_EX);
if (!$fp) {
echo "<p>your order is not processed at this time.
Please try again later.</p></body></html>";
exit;
}
fwrite($fp, $putstrings,strlen($putstrings));
flock($fp, LOCK_UN);
fclose($fp);
echo "Order Written!";
?>
</body>
</html>
#3
这是记事本的问题,你用 notepad++之类的编辑器打开文本文件就好了。
#4
这个与tab等于多少空格有关。记事本貌似是是8。
#5
用editplus3和sublime2打开还是一样的,有点晕
#1
木有人回答么
#2
源代码如下,是两个文件,一个提交数据,一个处理数据。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<style>
dl,dt,dd {margin: 0;}
</style>
</head>
<body>
<form action="processorder.php" method="post">
<div>
<dl>
<dt>Item</dt>
<dd>Quantity</dd>
<dt>Tires</dt>
<dd><input type="text" name="tireqty"/></dd>
<dt>oil</dt>
<dd><input type="text" name="oilqty"/></dd>
<dt>Spark plugs</dt>
<dd><input type="text" name="sparkqty"/></dd>
<dt>Shop Address</dt>
<dd><input type="text" name="address"/></dd>
<input type="submit" value="Submit Orders" />
</dl>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>Order Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
</head>
<body>
<h1>Bob's auto Parts</h1>
<h2>Order Results</h2>
<?php
echo "<p>Order Precessed at ";
echo date('H:i,jS F');
echo "</p>";
?>
<?php
$totalqty = 0;
print_r($_POST);
echo "<br />";
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty= $_POST['sparkqty'];
$address = $_POST['address'];
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$totalqty = $tireqty+$oilqty+$sparkqty;
$date = date('H:i,jS F Y');
echo "Item Ordered: $totalqty<br />";
if ($totalqty==0) {
echo "You did not order anything on the Bob's site!";
} else {
if ($tireqty>0) {
echo $tireqty."tireqty<br />";
}
if ($oilqty>0){
echo $oilqty."oilqty<br />";
}
if ($sparkqty>0) {
echo $sparkqty."sparkqty<br />";
}
}
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OLIPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty*TIREPRICE
+$oilqty*OLIPRICE
+$sparkqty*SPARKPRICE;
$totalamount = number_format($totalamount,2,'.','');
echo "<p>Totalamount is $".$totalamount."</p>";
$tax_rate = 0.1;
$totalamount = $totalamount*(1+$tax_rate);
echo "Total including tax:$".$totalamount."<br />";
$putstrings =$date."\t".$tireqty." tires\t".$oilqty." oil\t".$sparkqty." spark plugs\t"."Totalamount $".$totalamount."\t"."Address ".$address."\r\n";
print_r($DOCUMENT_ROOT);
@$fp = fopen("$DOCUMENT_ROOT/../orders/order.txt", 'ab');
flock($fp, LOCK_EX);
if (!$fp) {
echo "<p>your order is not processed at this time.
Please try again later.</p></body></html>";
exit;
}
fwrite($fp, $putstrings,strlen($putstrings));
flock($fp, LOCK_UN);
fclose($fp);
echo "Order Written!";
?>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<style>
dl,dt,dd {margin: 0;}
</style>
</head>
<body>
<form action="processorder.php" method="post">
<div>
<dl>
<dt>Item</dt>
<dd>Quantity</dd>
<dt>Tires</dt>
<dd><input type="text" name="tireqty"/></dd>
<dt>oil</dt>
<dd><input type="text" name="oilqty"/></dd>
<dt>Spark plugs</dt>
<dd><input type="text" name="sparkqty"/></dd>
<dt>Shop Address</dt>
<dd><input type="text" name="address"/></dd>
<input type="submit" value="Submit Orders" />
</dl>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>Order Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
</head>
<body>
<h1>Bob's auto Parts</h1>
<h2>Order Results</h2>
<?php
echo "<p>Order Precessed at ";
echo date('H:i,jS F');
echo "</p>";
?>
<?php
$totalqty = 0;
print_r($_POST);
echo "<br />";
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty= $_POST['sparkqty'];
$address = $_POST['address'];
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$totalqty = $tireqty+$oilqty+$sparkqty;
$date = date('H:i,jS F Y');
echo "Item Ordered: $totalqty<br />";
if ($totalqty==0) {
echo "You did not order anything on the Bob's site!";
} else {
if ($tireqty>0) {
echo $tireqty."tireqty<br />";
}
if ($oilqty>0){
echo $oilqty."oilqty<br />";
}
if ($sparkqty>0) {
echo $sparkqty."sparkqty<br />";
}
}
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OLIPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty*TIREPRICE
+$oilqty*OLIPRICE
+$sparkqty*SPARKPRICE;
$totalamount = number_format($totalamount,2,'.','');
echo "<p>Totalamount is $".$totalamount."</p>";
$tax_rate = 0.1;
$totalamount = $totalamount*(1+$tax_rate);
echo "Total including tax:$".$totalamount."<br />";
$putstrings =$date."\t".$tireqty." tires\t".$oilqty." oil\t".$sparkqty." spark plugs\t"."Totalamount $".$totalamount."\t"."Address ".$address."\r\n";
print_r($DOCUMENT_ROOT);
@$fp = fopen("$DOCUMENT_ROOT/../orders/order.txt", 'ab');
flock($fp, LOCK_EX);
if (!$fp) {
echo "<p>your order is not processed at this time.
Please try again later.</p></body></html>";
exit;
}
fwrite($fp, $putstrings,strlen($putstrings));
flock($fp, LOCK_UN);
fclose($fp);
echo "Order Written!";
?>
</body>
</html>
#3
这是记事本的问题,你用 notepad++之类的编辑器打开文本文件就好了。
#4
这个与tab等于多少空格有关。记事本貌似是是8。
#5
用editplus3和sublime2打开还是一样的,有点晕