当前位置: 代码迷 >> PHP >> php提交表单后出现http500异常
  详细解决方案

php提交表单后出现http500异常

热度:256   发布时间:2016-04-28 20:15:40.0
php提交表单后出现http500错误

新手,刚接触php,麻烦各位大神了
html部分
<html>
<head>
<title>Popcorn sales</title>
</head>
<body>
<form action="http://localhost/my_php1/Popcorn_sales.php" method="post">
<h2>Welcome to here!</h2>
<table>
<tr>
   <td>Buyer's Name:</td>
   <td><input type="text" name="name" size="30"/></td>
</tr>
<tr>
<td>Street Adress:</td>
<td><input type="text" name="street" size="30"/></td>
</tr>
<tr>
<td>City,State,Zip:</td>
<td><input type="text" name="city" size="30"/></td>
</tr>
</table>
<p>
<table border="border">
<tr>
<th>Product</th>
<th>Price</th>
<th>Quantity</th>
</tr>
<tr>
<td>Unpopped Popcorn(1 1b.)</td>
<td>$3.00</td>
<td align="center"><input type="text" name="unpop" size="3"/></td>
</tr>
<tr>
<td>Caramel Popcorn</td>
<td>$3.50</td>
<td align="center"><input type="text" name="caramel" size="3"/></td>
                </tr>
                <tr>
<td>Caramel Nut Popcorn(1 1b.)</td>
<td>$4.50</td>
<td align="center"><input type="text" name="caramelnut" size="3"/></td>
</tr>
<tr>
<td>Toffey Nut Popcorn(1 1b.)</td>
<td>$5.00</td>
<td align="center"><input type="text" name="toffeynut" size="3"/></td>
</tr>
</table>
</p>
<h3>Payment Method</h3>
<p>
<input type="radio" name="payment" value="visa" checked="checked"/>Visa<br/>
<input type="radio" name="payment" value="mastercard" checked="checked"/>Master Card<br/>
<input type="radio" name="payment" value="discover" checked="checked"/>Discover<br/>
<input type="radio" name="payment" value="check" checked="checked"/>Check<br/><br/>
    <input type="submit" value="Submit Order"/>
    <input type="reset" value="Submit Order"/>
</p>
</form>
</body>
</html>


php程序
<html>
<head>
<title>Process the popcorn.html form</title>
</head>
<body>
<?php
$unpop=$_post["unpop"];
$caramel=$_post["caramel"];
$caramelnut=$_post["caramelnut"];
$toffeynut=$_post["toffeynut"];
$name=$_post["name"];
$street=$_post["street"];
$city=$_post["city"];
$payment=$_post["payment"];
if($unpop=="") $unpop=0;
if($caramel=="") $caramel=0;
if($caramelnut=="") $caramelnut=0;
if($toffeynut=="") $toffeynut=0;
$unpop_cost=3.0*$unpop;
$caramel_cost=3.5*$caramel;
$caramelnut_cost=4.5*$caramelnut;
$toffeynut_cost=5.0*$toffeynut;
$total_price=$unpop_cost+$caramel_cost+$caramelnut_cost+$toffeynut_cost;
$total_items=$unpop+$caramel+$caramelnut+$toffeynut;
?>
<h4>Customer:</h4>
<!--<?php print($total_items,$total_price); ?>-->
<?php
print("$name<br/>$street<br/>$city<br/>");
?>
<p/><p/>
<table border="border">
<caption>Order Information</caption>
<tr>
<th>Product</th>
<th>Unit Price</th>
<th>Quantity Ordered</th>
<th>Item Cost</th>
</tr>
<tr align="center">
<td>Unpopped Popcorn</td>
<td>$3:00</td>
<td><?php print("$unpop"); ?></td>
    <td><?php printf("$ %4.2f",$unpop_cost); ?></td>
</tr>
<tr align="center">
<td>Caramel Popcorn</td>
<td>$3:50</td>
<td><?php print("$caramel"); ?></td>
    <td><?php printf("$ %4.2f",$caramel_cost); ?></td>
</tr>
<tr align="center">
<td>Caramel Nut Popcorn</td>
<td>$4:50</td>
<td><?php print("$caramelnut"); ?></td>
    <td><?php printf("$ %4.2f",$caramelnut_cost); ?></td>
</tr>
<tr align="center">
<td>Toffey Nut Popcorn</td>
<td>$5:00</td>
<td><?php print("$toffeynut"); ?></td>
    <td><?php printf("$ %4.2f",$toffeynut_cost); ?></td>