当我单击表单的提交按钮时,会出现以下错误消息:
"未声明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)
我不知道我的代码中的问题在哪里.请帮我.
我有一个文件夹'items',其中有3个文件item1.txt, item2.txt and item3.txt.
我想delete item2.txt从文件夹中归档.我使用以下代码,但它不从文件夹中删除文件.任何身体都可以帮助我.
<?php
$data="item2.txt";
$dir = "items";
$dirHandle = opendir($dir);
while ($file = readdir($dirHandle)) {
if($file==$data) {
unlink($file);
}
}
closedir($dirHandle);
?>
Run Code Online (Sandbox Code Playgroud) 在下面的PHP代码中,我试图回显$ title和$ desc的值,但它不显示仅显示变量名称的值.任何帮助将不胜感激.
foreach ($prod as $product) {
$title=$product['title'];
$desc=$product['desc'];
echo '
<div class="detail">
<div class="img"><img src="images/pro1.png"/></div>
<div class="textdetail"><p><b>$title</b><br /></p>
<p><a href="#">$desc</a></p>
</div><br />
</div>';
}
Run Code Online (Sandbox Code Playgroud)