aboutsummaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2021-04-29 18:04:56 +0300
committerAqua-sama <aqua@iserlohn-fortress.net>2021-04-29 18:04:56 +0300
commit4cee97e695c889445c3146bc8169a89b132855ea (patch)
tree693489f2f89f86e277255dfe0f9d5482ecad0359 /user
parentAdd nginx and php-fpm config files (diff)
downloadbugtracker-4cee97e695c889445c3146bc8169a89b132855ea.tar.xz
Finish user management
Diffstat (limited to 'user')
-rw-r--r--user/delete.php25
-rw-r--r--user/index.php6
2 files changed, 31 insertions, 0 deletions
diff --git a/user/delete.php b/user/delete.php
new file mode 100644
index 0000000..b46cdce
--- /dev/null
+++ b/user/delete.php
@@ -0,0 +1,25 @@
+<?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 = $conn->prepare("DELETE FROM users WHERE id = :id");
+$query->bindParam(':id', $_SESSION['user_id']);
+
+if($query->execute()) {
+ echo '<h2>Account successfully deleted</h2>';
+ unset($_SESSION['user_name']);
+ unset($_SESSION['user_id']);
+} else {
+ echo '<h2>Account deletion failed</h2>';
+}
+}
+
+header("Refresh: 2; URL={$config['urls']['base']}");
+
+require_once(TEMPLATES_PATH . "/footer.php");
+?>
+
diff --git a/user/index.php b/user/index.php
index 90b3a84..dec49ba 100644
--- a/user/index.php
+++ b/user/index.php
@@ -32,6 +32,12 @@ if (isset($_SESSION['user_id']) && $_SESSION['user_id'] != "") {
</form>
</div>
+<div id='user_delete_account'>
+<form action='<?php echo "{$config['urls']['base']}/user/delete.php"; ?>' method='post'>
+ <input type='submit' value='delete account' >
+</form>
+</div>
+
<?php
} else {
# not logged in