php表单上的奇怪编码字符

时间:2017-07-19 03:04:36

标签: php encoding

我正在尝试学习PHP表单,输入数据,使用按钮在基本的html表单页面上输出结果。但是,它并没有将我发送到正确的PHP链接,而是显示了404找不到的链接,而且似乎我在apache上遇到了一些奇怪的编码问题。

我甚至将其上传到我的托管服务器,我对链接进行了进一步的奇怪编码,这个编码应该被命名为handle_calc.php

  

在此服务器上找不到请求的URL /•¡¡¡

有什么提示,需要改变什么?我很惊讶默认情况下两个环境都不能正确显示基本格式的PHP。

HTML

<!doctype html>
<html lang=“en”>
<head>
<meta charset=“utf-8”>
<title>Product Cost Calculator</title>
</head>
<body>

<div><p>Fill out this form to calculate the total cost:</p>

<form action=“handle_calc.php” method=“post”>

<p>Price: <input type=“text” name=“price” size=“5”></p>

<p>Quantity: <input type="number" name=“quantity” size=“5” min=“1” 
value=“1”></p>

<p>Discount: <input type=“text” name=“discount” size=“5”></p>

<p>Tax: <input type=“text” name=“tax” size=“5”> (%)</p>

<p>Shipping method: <select name=“shipping”>
<option value=“5.00”>Slow and steady</option>
<option value=“8.95”>Put a move on it.</option>
<option value=“19.36”>I need it yesterday!</option>
</select></p>

<p>Number of payments to make: <input type="number" name="payments" size=“5” 
min=“1” value=“1”></p>

<input type="submit" name="submit" value="Calculate!">

</form>

</div>

</body>

</html>

PHP:

 <!doctype html>
<html lang=“en”>
<head>
 <meta charset=“utf-8”>
<title>Product Cost Calculator</title>

<style type=“text/css”>
 .number { font-weight: bold; }
</style>

</head>
<body>

<?php

//get the values from the $_POST array

$price = $_POST[‘price’];
$quantity = $_POST[‘quantity’];
$discount = $_POST[‘discount’];
$tax = $_POST[‘tax’];
$shipping = $_POST[‘shipping’];
$payments = $_POST[‘payments’];

//calculate the total:

$total = $price * $quantity;
$total = $total + $shipping;
$total = $total - $discount;

//determine tax rate

$taxrate = $tax / 100;
$taxrate = $taxrate + 1;

//factor in the tax rate:
$total = $total * $taxrate;

//calculate the monthly payments
$monthly = $total / $payments

//print out results

print “<p>You have selected to purchase:<br>
<span class=\”number\”>$quantity</span> widget(s) at <br>
$<span class=\”number\”>$price</span>price each plus a <br>
$<span class=\”number\”>$shipping</span>shipping cost and a <br>
<span class=\”number\”>$tax</span>percent tax rate.<br>
After your $<span class=\”number\”>$discount</span>discount, the total cost 
is $<span class=\”number\”>$total</span>.<br>
Divided over <span class=\”number\”>$payments</span>monthly payments, that 
would be $<span class=\”number\”>$monthly</span> each.</p>”;

?>

</body>
</html>

1 个答案:

答案 0 :(得分:1)

您的表单操作属性使用特殊字符而不是标准双引号。您似乎始终使用特殊字符。用常规的双/单引号替换所有出现的特殊字符。