我是一个新的 PHP 编码器,我开始了一个 cms 面板项目,开始时有三个选项:新文章、删除文章和编辑文章。我的项目中甚至没有一个错误,但是,当我尝试编辑一篇文章时,一切都很顺利,除了保存。帖子没有保存!!!并且没有任何错误!我正试图从昨天开始解决这个问题。这很烦人。
这是我的代码的一部分:
编辑处理.php:
<!DOCTYPE html>
<?php
include("includes/functions.php");
$ctreat = getTreat($_GET["id"]);
?>
<html lang="en">
<head>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<meta charset="utf-8" />
<title>Control panel</title>
</head>
<body>
<form action="doEditt.php" method="post">
<table>
<tr>
<td>
<label for="tName">:Title</label>
</td>
<td>
<input type="text" name="tName" value="<?php echo $ctreat["Title"]; ?>"></input>
</td>
</tr>
<tr>
<td>
<label for="tContent">:Content</label>
</td>
<td>
<textarea name="tContent"> <?php echo $ctreat["Content"]; ?> </textarea>
<script type="text/javascript">
CKEDITOR.replace('tContent');
</script>
</td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="Edit"></input></td>
<td> <input type="hidden" name="id" value="<?php echo $_GET["ID"]; ?>" /></td>
</tr>
</table>
</form>
</body>
</html>
doEditt.php:
<?php
include("includes/functions.php");
if(isset($_POST["submit"])) {
if(isset($_POST["tName"])) {
editTreat($_POST["tName"],$_POST["tContent"],$_POST["id"]);
header("Location: treatments.php");
} else {
echo "Please fill the title";
include("editTreat.php");
}
} else {
header("Location: editTreat.php");
}
?>
我的 include/functions.php 的一部分:
function editTreat($tName, $tContent, $id) {
$id = (int) $id;
$query = mysql_query("UPDATE `treatments` SET title = '$tName', content = '$tContent' WHERE ID = '$id'") or die(mysql_error());
header("Location: treatments.php");
}
function getTreat($id) {
$id = (int) $id;
$query = mysql_query("SELECT * FROM `treatments` WHERE ID = '$id'") or die(mysql_error());
return mysql_fetch_assoc($query);
}
所以,如果你能帮助我,请帮助我。谢谢!!