From fd4cb27121122d146b8cc3d55ad5aa9312c2cbe6 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Wed, 7 Apr 2021 11:49:12 +0300 Subject: Initial commit --- update.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 update.php (limited to 'update.php') diff --git a/update.php b/update.php new file mode 100644 index 0000000..f27cdd4 --- /dev/null +++ b/update.php @@ -0,0 +1,35 @@ +No bug selected, redirecting to index..."; + header('Refresh: 2; URL=index.php'); + +} else if(!isset($_SESSION['user_id']) || $_SESSION['user_id'] == "") { + echo "
Not logged in, redirecting to index...
"; + header('Refresh: 2; URL=index.php'); + +} else { + $conn = new PDO($config['db']['dsn'], $config['db']['username'], $config['db']['password']); + + $query = $conn->prepare("UPDATE bugs SET title=:title, description=:description WHERE id=:id"); + $query->bindParam(':title', $_POST['title']); + $query->bindParam(':description', $_POST['description']); + $query->bindParam(':id', $_GET['id']); + + if ($query->execute()) { + echo "Data is updated\n"; + } else { + echo "User must have sent wrong inputs\n"; + } + + header("Refresh: 2; URL=view.php?id=$_GET[id]"); + +} + +require_once(TEMPLATES_PATH . "/footer.php"); +?> + -- cgit v1.2.1