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 템플릿의 HEAD 섹션에 첫 줄로 추가하십시오.
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
가장 기본적인 상황과 동일한 문제가 있으며이 메타를 머리에 삽입하여 문제를 해결했습니다.
<meta charset="UTF-8">
html 문서의 문자 인코딩 (실제로 UTF-8 임)이 선언되지 않았습니다
글을 $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>
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>
파일을 .html에서 .php로 변경해야합니다.
이 라인을 추가하십시오
header('Content-Type: text/html; charset=utf-8');
Your initial page is a complete HTML page containing a form, the contents of which are posted to insert.php when the submit button is clicked, but insert.php needs to process the form's contents and do something with them, like add them to a database, or output them to a new page. Your current insert.php just outputs the contents of the title field, so your browser tries to interpret that as an HTML page, and fails, obviously, because it isn't valid HTML (i.e. it isn't contained in an 'HTML' tag, etc.).
Your insert.php needs to output the necessary HTML, and insert the form data in there somewhere.
For example:
<?php
$title = $_POST["title"];
$price = $_POST["price"];
echo '<html xmlns="http://www.w3.org/1999/xhtml">';
echo '<head>';
echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
echo '<title>';
echo $title;
echo '</title>';
echo '</head>';
echo '<body>';
echo 'Hello, world.';
echo '</body>';
?>
'Programing' 카테고리의 다른 글
node.js에서 process.env.PORT의 값을 변경하는 방법은 무엇입니까? (0) | 2020.06.26 |
---|---|
파이썬에서 고유 ID를 어떻게 생성 할 수 있습니까? (0) | 2020.06.26 |
키 저장소 정보를 build.gradle에 넣지 않고 APK에 서명 (0) | 2020.06.26 |
jQuery : 목록 요소의 수를 세시겠습니까? (0) | 2020.06.26 |
팬더에서 데이터 프레임의 처음 세 행을 삭제하십시오. (0) | 2020.06.26 |