delete($id)) { header('Location: index.php'); } // 修改失敗 else { header('Location: edit.php?id='.$id); } } // 修改資料 elseif (!empty($_POST['id'])) { $id = $_POST['id']; $title = $_POST['title']; $content = $_POST['content']; // 修改成功 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'); } }