2020-04-09 01:38:29 +08:00

33 lines
695 B
PHP

<?php
$title = $_POST['title'];
$content = $_POST['content'];
require_once 'config.php';
require_once FOLDER_ROOT.'/lib/Database/DbMessage.php';
use MessageBoard\Database\DbMessage;
$db = new DbMessage();
// 修改資料
if (!empty($_POST['id'])) {
$id = $_POST['id'];
// 修改成功
if ($db->edit($id, $title, $content)) {
header('Location: view.php?id='.$id);
}
// 修改失敗
else {
header('Location: edit.php?id='.$id);
}
}
// 新增資料
else {
// 修改成功
if ($id = $db->insert($title, $content)) {
header('Location: view.php?id='.$id);
}
// 修改失敗
else {
header('Location: edit.php');
}
}