php提交表单后出现http500错误

gglinux 2013-12-04 04:48:09

新手,刚接触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>
</tr>
<tr align="center">
<td>Unpopped Popcorn</td>
<td>$3:00</td>
<td><?php print("$caramel");?></td>
<td><?php printf("$ %4.2f",$unpop_cost);?></td>
</tr>
</table>
<p /><p />
<?php
print("You odered $total_items popcorn items <br/>");
printf("Your total bill is:$ %5.2f<br />",$total_price);
print("Your chosen method of payment is:$payment <br />");
?>
</body>
</html>
...全文
604 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2013-12-04
  • 打赏
  • 举报
回复
对!错误能够显示在浏览器上
gglinux 2013-12-04
  • 打赏
  • 举报
回复
刚刚又试下就好了。不知道是什么原因,可能还是改php.in后好的,display_errors=On有什么用了?是错误能够显示在浏览器上面吗?
gglinux 2013-12-04
  • 打赏
  • 举报
回复
改了之后,apache,浏览器重启还是这样的。郁闷。。。我的apache版本比较低,难道是版本的问题。但是这个代码就行得通 <html> <head> <title>php2</title> </head> <body> <form name="form2" method="post" action="http://localhost/my_php2/php2.php"> <table border="border"> <tr> <td>管理员:</td> <td><input type="text" name="username" size="20"></td> </tr> <tr> <td>密码:</td> <td><input type="password" name="password" size="20"></td> </tr> <td>提交:</td> <td><input type="submit" name="Submit" value="提交"></td> </tr> </table> </form> <?php //if ($Submit=="提交") { $username=$_POST[username]; $password=$_POST[password]; //} ?> <table> <tr> <td>管理员:<?php print($username) ?></td> </tr> <tr> <td>密码:<?php print($password) ?></td> </tr> </table> </body> </html>
一起混吧 2013-12-04
  • 打赏
  • 举报
回复
php.ini 中令 display_errors=On ,然后重启服务器再运行看看。
xuzuning 2013-12-04
  • 打赏
  • 举报
回复
在浏览中直接运行当然不行,你得要提交
gglinux 2013-12-04
  • 打赏
  • 举报
回复
POST,大写之后,还是有错误
gglinux 2013-12-04
  • 打赏
  • 举报
回复
嗯嗯,POST要大写。 一楼:apache没有问题的,刚刚写了另外一个表单的的代码,能够正常运行。 至于二楼和三楼:你们说的这段代码原本是调试用的,没有成功,就被注销了。但是没有被删除
xuzuning 2013-12-04
  • 打赏
  • 举报
回复
$unpop=$_post["unpop"]; $caramel=$_post["caramel"]; $caramelnut=$_post["caramelnut"]; $toffeynut=$_post["toffeynut"]; $name=$_post["name"]; $street=$_post["street"]; $city=$_post["city"]; $payment=$_post["payment"]; 你们都没看到这段代码会报未定义变量警告吗? 如果未开启错误显示,那自然就是 500 错了 $_post 应写作 $_POST
码无边 2013-12-04
  • 打赏
  • 举报
回复
<!--<?php print($total_items,$total_price); ?>--> 这是什么东东?
森之树 2013-12-04
  • 打赏
  • 举报
回复
<!--<?php print($total_items,$total_price); ?>--> 这代码错误
黄袍披身 2013-12-04
  • 打赏
  • 举报
回复
500是个内部错误...原因多面. 换个apache 吧

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧