aboutsummaryrefslogtreecommitdiff
path: root/bug/delete.php
blob: 905415120e9f0996c8800769d6981fc80807e553 (plain)
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
<?php
require '../config.php';
require_once(TEMPLATES_PATH . "/header.php");
require_once(TEMPLATES_PATH . "/panel.php");
require_once(LIBRARY_PATH . "/functions.php");

if(!session_set()) {
    echo "You need to be logged in";
    goto redirect;
}

if($_GET['id'] == "") {
    echo "No bug to delete";
    goto redirect;
}

$conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
$query = $conn->prepare("DELETE FROM bugs WHERE id=:bug_id");
$query->bindParam(':bug_id', $_GET['id']);
if($query->execute()) {
    echo "<h2>bug deleted</h2>";
} else {
    echo "<h2>bug failed to delete</h2>";
}

redirect: header("Refresh: 2; URL=$_SERVER[HTTP_REFERER]");
footer: require_once(TEMPLATES_PATH . "/footer.php");
?>