当我单击表单的提交按钮时,会出现以下错误消息:
"未声明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>
Run Code Online (Sandbox Code Playgroud)
insert.php:
<?php
$title = $_POST["title"];
$price = $_POST["price"];
echo $title;
?>
Run Code Online (Sandbox Code Playgroud)
我不知道我的代码中的问题在哪里.请帮我.
Kri*_*pal 235
将其添加为HTML模板的HEAD部分中的第一行
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
Run Code Online (Sandbox Code Playgroud)
小智 36
我对最基本的情况有同样的问题,我的问题通过在头部插入这个元素来解决:
<meta charset="UTF-8">
Run Code Online (Sandbox Code Playgroud)
未声明html文档的字符编码(实际上是UTF-8)
Ali*_*guy 17
好吧,当你发布时,浏览器只输出$title- 你的所有HTML标签和doctype都会消失.您需要在insert.php文件中包含这些内容:
<!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>
<?php
$title = $_POST["title"];
$price = $_POST["price"];
echo $title;
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在Firefox中运行表单应用程序时,我遇到了同样的问题。添加<meta charset="utf-8"/>html代码解决了我在Firefox中的问题。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Voice clip upload</title>
<script src="voiceclip.js"></script>
</head>
<body>
<h2>Upload Voice Clip</h2>
<form id="upload_form" enctype="multipart/form-data" method="post">
<input type="file" name="file1" id="file1" onchange="uploadFile()"><br>
<progress id="progressBar" value="0" max="100" style="width:300px;"></progress>
</form>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
234592 次 |
| 最近记录: |