PHP+ACCESS 文章管理程序代码

2019-04-09 18:47:08丽君

. "</form>rn";
//增加一个类别
if(@$_GET["class"] == "add"){
if(@$_POST["class_name"] == "" || @$_POST["class_cid"] == ""){
echo "<br />填写不完整!";
echo "<script language="JavaScript">setTimeout("history.back();", 2000);</script>";
exit();
}
else {
@$sql = "Insert into List(by_list,by_cid) Values('" . $_POST["class_name"] . "' , '" . $_POST["class_cid"] . "')";
$conn->Execute($sql);
echo "<br />添加成功!";
echo "<script language="JavaScript">setTimeout("window.location.href='?admin=class';", 2000);</script>";
}
}
//修改一个类别
if(@$_GET["class"] == "edit"){
if(@$_POST["class_" . $_GET["id"]] == "" || @$_POST["class_cid_" . $_GET["id"]] == ""){
echo "<br />填写不完整!";
echo "<script language="JavaScript">setTimeout("history.back();", 2000);</script>";
exit();
}
else {
@$sql = "Update List Set by_list = '" . $_POST["class_" . $_GET["id"]] . "' , by_cid = '" . $_POST["class_cid_" . $_GET["id"]] . "' Where id = " . $_GET["id"];
$conn->Execute($sql);
echo "<br />修改成功!";
echo "<script language="JavaScript">setTimeout("window.location.href='?admin=class';", 2000);</script>";
}
}
//删除一个类别
if(@$_GET["class"] == "del"){
@$sql = "Delete From List Where id = " . $_GET["id"];
$conn->Execute($sql);
echo "<br />删除成功!";
echo "<script language="JavaScript">setTimeout("window.location.href='?admin=class';", 100);</script>";
}
}
//==================================
//后台:发表文章(支持HTML)
//==================================
function admin_insert(){
global $conn;
if(@$_GET["innert"] == "add"){
if(@$_POST["title"] == "" || @$_POST["name"] == "" || @$_POST["class"] == "" || @$_POST["body"] == ""){
echo "<br />填写不完整!";
echo "<script language="JavaScript">setTimeout("history.back();", 2000);</script>";
exit();
}
else {
@$body = $_POST["body"];
$body = str_replace("'", "''", $body);
$body = str_replace("rn", "<br />", $body);
@$sql = "Insert into article(by_title,by_name,by_time,by_count,by_body,by_class) Values('" . $_POST["title"] . "' , '" . $_POST["name"] . "' , #" . date("Y-m-d G:i:s") . "# , 0 , '" . $body . "' , '" . $_POST["class"] . "')";
$conn->Execute($sql);
echo "<br />添加成功!";
echo "<script language="JavaScript">setTimeout("window.location.href='?admin=insert';", 2000);</script>";
}
}
else {
echo "<div style="width:590px;text-align:left">rn"
. "<form action="?admin=insert&innert=add" method="post">rn"
. "文章标题:<input type="text" name="title" /><br />rn"
. "文章作者:<input type="text" name="name" /><br />rn"
. "文章类别:<select name="class">rn";
相关文章 大家在看