HTML 문서의 문자 인코딩이 선언되지 않았습니다.

폼의 송신 버튼을 클릭하면, 다음의 에러 메세지가 표시됩니다.

HTML 문서의 문자 인코딩이 선언되지 않았습니다.문서가 US-ASCII 범위를 벗어난 문자를 포함하는 경우 일부 브라우저 구성에서 왜곡된 텍스트로 렌더링됩니다.페이지의 문자 인코딩은 문서 또는 전송 프로토콜에서 선언해야 합니다.

insert.interval:

<!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.interval:

<?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)이 선언되지 않았습니다.

여기여기랑 더 자세히.




Firefox에서 폼 어플리케이션을 실행했을 때도 같은 문제가 있었습니다.추가 중<meta charset="utf-8"/>HTML 코드로 파이어폭스의 문제를 해결했습니다.

<!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>




글을 올리면 브라우저는 출력만 합니다.$title– 모든 HTML 태그와 doctpe를 제거합니다.이러한 항목을 포함시켜야 합니다.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> 



파일을 .html에서 .php로 변경해야 합니다.

다음 행을 추가합니다.

header('Content-Type: text/html; charset=utf-8');