aboutsummaryrefslogtreecommitdiff
path: root/report/update.php
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-04-29 20:43:35 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2021-04-29 20:43:35 +0300
commit7319816b7c712cd16d6e83bcd617c95943b79be6 (patch)
treeae5de7c1e2a4387c50ee1df53b24b0021be5c591 /report/update.php
parentFinish user management (diff)
downloadbugtracker-7319816b7c712cd16d6e83bcd617c95943b79be6.tar.xz
CRUD reports
Diffstat (limited to 'report/update.php')
-rw-r--r--report/update.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/report/update.php b/report/update.php
new file mode 100644
index 0000000..0fadb53
--- /dev/null
+++ b/report/update.php
@@ -0,0 +1,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()) {
+ $conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']);
+ $query = $_POST['id'] == "" ?
+ $conn->prepare("INSERT INTO reports (author, title, description) VALUES (:user_id, :title, :description)")
+ : $conn->prepare("UPDATE reports SET title=:title, description=:description WHERE id=:report_id");
+ if($_POST['id'] == "") {
+ $query->bindParam(':user_id', $_SESSION['user_id']);
+ } else {
+ $query->bindParam(':report_id', $_POST['id']);
+ }
+ $query->bindParam(':title', $_POST['title']);
+ $query->bindParam(':description', $_POST['description']);
+ if($query->execute()) {
+ echo "<h2>report submitted</h2>";
+ } else {
+ echo "<h2>report failed to submit</h2>";
+ }
+}
+
+header("Refresh: 2; URL=$_SERVER[HTTP_REFERER]");
+footer: require_once(TEMPLATES_PATH . "/footer.php");
+?>