89 lines
2.4 KiB
PHP
89 lines
2.4 KiB
PHP
<?php
|
|
|
|
require_once 'config.php';
|
|
require_once FOLDER_ROOT.'/lib/Database/DbMessage.php';
|
|
use MessageBoard\Database\DbMessage;
|
|
|
|
if (!empty($_GET["id"])) {
|
|
$id = $_GET["id"];
|
|
$db = new DbMessage();
|
|
if(!$item = $db->getDataByid($id)) {
|
|
header('Location: index.php');
|
|
}
|
|
$title = $item['title'];
|
|
$content = $item['content'];
|
|
}
|
|
else {
|
|
$title = '';
|
|
$content = '';
|
|
}
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="css/general.css">
|
|
<title>Document</title>
|
|
<style>
|
|
section>form ul li {
|
|
list-style-type: none;
|
|
margin-bottom: 1em;
|
|
}
|
|
|
|
section>form label input[type=text]{
|
|
width: 100%;
|
|
}
|
|
|
|
section>form label textarea{
|
|
width: 100%;
|
|
height: 15em;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="container">
|
|
<header>
|
|
<h1>留言板 編輯</h1>
|
|
</header>
|
|
<div id="main">
|
|
<section>
|
|
<form action="save.php" method="POST">
|
|
<?php
|
|
if (!empty($id)) {
|
|
echo '<input type="hidden" name="id" value="'.$id.'">';
|
|
}
|
|
?>
|
|
<ul>
|
|
<li>
|
|
<label>
|
|
<span>Title: </span>
|
|
<input type="text" name="title" value="<?php echo $title; ?>" required />
|
|
</label>
|
|
</li>
|
|
<li>
|
|
<label>
|
|
<span>Content: </span>
|
|
<textarea name="content"><?php echo $content; ?></textarea>
|
|
|
|
<textarea name="content">
|
|
111
|
|
222
|
|
333
|
|
</textarea>
|
|
</label>
|
|
</li>
|
|
</ul>
|
|
<ul class="func-btn">
|
|
<li><input type="submit" class="btn green" value="儲存"></li>
|
|
<li><input type="reset" class="btn" value="回復"></li>
|
|
<li><a href="index.php" class="btn">回首頁</a></li>
|
|
</ul>
|
|
</form>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|