forked from derrickyoo/expendable-news
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processdelete.php
27 lines (19 loc) · 748 Bytes
/
processdelete.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
<?php
session_start();
if (!isset($_SESSION['username']) || empty($_SESSION['username'])) {
die("You are not logged in. <a href='login.php'>Log In</a>");
}
if (isset($_SESSION['username']) && $_SESSION['superuser'] == 0) {
die("You do not have administrator access. <a href='index.php'>Back to Expendable News</a>");
}
// sets up a database connection
require_once('db.inc.php');
$delete_posts_query = $db->prepare("DELETE FROM `posts` WHERE `post_id`=:post_id");
$delete_comments_query = $db->prepare("DELETE FROM `comments` WHERE `post_id`=:post_id");
$params = array (
':post_id' => $_GET['id']
);
$delete_posts_query->execute($params);
$delete_comments_query->execute($params);
header('Location: index.php')
?>