forked from if-itb/IF3110-01-Simple-Blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.php
37 lines (27 loc) · 757 Bytes
/
handler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
include_once("assets/php/module/PostDataManager.php");
$data_mgr = new PostDataManager("assets/data", "assets/data");
if(empty($_GET)) {
$content = str_replace("\r\n", "<p>", $_POST["Konten"]);
$retval = $data_mgr->make_post($_POST["Judul"], $_POST["Tanggal"], $content);
if($retval !== false) {
header("Location: index.php");
} else {
print("Gagal membuat post baru!");
}
} else if($_GET["edit"] == "true") {
//print_r($_POST);
$content = str_replace("\r\n", "<p>", $_POST["Konten"]);
$retval = $data_mgr->edit_post(
$_POST["oldtitle"],
$_POST["olddate"],
$_POST["Judul"],
$_POST["Tanggal"],
$content);
if($retval !== false) {
header("Location: index.php");
} else {
print("Gagal mengedit post!");
}
}
?>