-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpost.process.php
30 lines (21 loc) · 887 Bytes
/
post.process.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
<?php
include "./includes/class-autoload.inc.php";
$posts = new Posts();
if(isset($_POST['submit'])) {
$title = $_POST['post-title'];
$body = $_POST['post-content'];
$author = $_POST['post-author'];
$posts->addPost($title, $body, $author);
header("location: {$_SERVER['HTTP_ORIGIN']}/PHP-OOP/crud_pdo_oop/index.php?status=added");
} else if($_GET['send'] === 'del') {
$id = $_GET['id'];
$posts->delPost($id);
header("location: {$_SERVER['HTTP_ORIGIN']}/PHP-OOP/crud_pdo_oop/index.php?status=deleted");
} else if($_GET['send'] === 'update') {
$id = $_GET['id'];
$title = $_POST['post-title'];
$body = $_POST['post-content'];
$author = $_POST['post-author'];
$posts->updatePost($id, $title, $body, $author);
header("location: {$_SERVER['HTTP_ORIGIN']}/PHP-OOP/crud_pdo_oop/index.php?status=updated");
}