當我點擊我的表單的提交按鈕會出現以下錯誤信息:HTML文檔的字符編碼未聲明
「的HTML文檔的字符編碼未聲明的文件將與亂碼的文字渲染在某些瀏覽器配置中,如果文檔包含US-ASCII範圍之外的字符,則頁面的字符編碼必須在文檔或傳輸協議中聲明。
insert.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">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>insert page</title></head>
<body>
<h1> Insert Page </h1>
<form action="insert.php" method="post" enctype="application/x-www-form-urlencoded" >
<p>Title:<input type="text" name="title" size="40"/></p>
<p>Price:<input type= "text" name="price" size="40" /></p>
<p><input type="submit" value="Insert" />
<input type="reset" value="Reset" /></p>
</form>
</body>
</html>
insert.php:
<?php
$title = $_POST["title"];
$price = $_POST["price"];
echo $title;
?>
我不知道哪裏是我的代碼的問題。請幫幫我。
一些好的閱讀:[在HTML中聲明的字符編碼(http://www.w3.org/International/questions/qa-html-encoding-declarations) – 2012-08-16 22:21:03
嘗試將您的.html頁面命名爲.php:'insert.html' - >'insert.php'。並將你的表單處理文件('insert.php')命名爲'insert_action.php'或其他東西。 (不知道它是否有幫助,但在使用PHP時,我不會混合'html'和'php'頁面。) – 2012-10-10 13:07:48
哦,親愛的,這是一個老問題。沒有注意到日期,因爲新的答案... – 2012-10-10 13:10:08