php版本没有那么高呦
时间: 2023-08-21 14:02:40 浏览: 50
好的,那么以下是 PHP 5.x 版本的代码:
表单的 HTML 代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Light Bulb Order Form</title>
</head>
<body>
<form method="post" action="order.php">
<label for="username">Username:</label>
<input type="text" id="username" name="username"><br>
<label>25W Bulbs:</label><br>
<input type="checkbox" name="bulbs[]" value="2.39">4 Pack<br>
<input type="checkbox" name="bulbs[]" value="4.29">8 Pack<br>
<label>25W Long-Life Bulbs:</label><br>
<input type="checkbox" name="bulbs[]" value="3.95">4 Pack<br>
<input type="checkbox" name="bulbs[]" value="7.49">8 Pack<br>
<label>Payment Method:</label><br>
<input type="radio" name="payment" value="Visa">Visa<br>
<input type="radio" name="payment" value="MasterCard">MasterCard<br>
<input type="radio" name="payment" value="Discover">Discover<br>
<input type="submit" value="Order">
</form>
</body>
</html>
```
PHP 脚本代码:
```php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Order Summary</title>
</head>
<body>
<h1>Order Summary</h1>
<p>Thank you for your order, <?php echo $_POST["username"]; ?>!</p>
<table>
<tr>
<th>Item</th>
<th>Price</th>
</tr>
<?php
$bulbs = $_POST["bulbs"];
$total = 0;
foreach ($bulbs as $bulb) {
$total += $bulb;
echo "<tr><td>25W Bulbs</td><td>$" . number_format($bulb, 2) . "</td></tr>";
}
$tax = $total * 0.062;
$total += $tax;
echo "<tr><td>Sales Tax</td><td>$" . number_format($tax, 2) . "</td></tr>";
echo "<tr><th>Total</th><th>$" . number_format($total, 2) . "</th></tr>";
?>
</table>
</body>
</html>
```
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)