blob: 0ee6e26ea17684bc4a3dfdbb2bc2de7bd0e00754 (
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
29
30
|
<?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()) {
$conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
$query = $_POST['id'] == "" ?
$conn->prepare("INSERT INTO bugs (author, title, description) VALUES (:user_id, :title, :description)")
: $conn->prepare("UPDATE bugs SET title=:title, description=:description WHERE id=:bug_id");
if($_POST['id'] == "") {
$query->bindParam(':user_id', $_SESSION['user_id']);
} else {
$query->bindParam(':bug_id', $_POST['id']);
}
$query->bindParam(':title', $_POST['title']);
$query->bindParam(':description', $_POST['description']);
if ($query->execute()) {
echo "Data is updated\n";
} else {
echo "Query failed\n";
}
}
header("Refresh: 2; URL=$_SERVER[HTTP_REFERER]");
footer: require_once(TEMPLATES_PATH . "/footer.php");
?>
|