delete entries in users

This commit is contained in:
2022-06-18 10:44:08 +02:00
parent fe877ea176
commit d842b431e0
3 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
<?php
session_start();
include("../scripts/connection.php");
include("../scripts/functions.php");
$user_data = check_admin($con);
if($_SERVER['REQUEST_METHOD'] == "POST") {
try {
$stmt = $con->prepare("DELETE FROM users WHERE id = :id");
$stmt->execute(['id' => $_POST['id']]);
} catch(PDOException $e) {
handle_pdo_exception($e);
}
}
$con = null;
header("Location: manage_user.php");
die;
?>

View File

@@ -17,6 +17,7 @@ function init() {
team_delete_button(); team_delete_button();
station_delete_button(); station_delete_button();
statistic_delete_button(); statistic_delete_button();
user_delete_button();
} }
var selected = null; var selected = null;
@@ -139,4 +140,18 @@ function statistic_delete_button() {
} }
} }
} }
}
function user_delete_button() {
var button = document.getElementById('delete_user');
if(button != null) {
button.onclick = function() {
var row = document.getElementsByClassName('selected')[0];
document.getElementById('id_delete').value = row.id;
let confirmAction = confirm("Wirklich löschen?");
if (confirmAction) {
this.form.submit();
}
}
}
} }

View File

@@ -22,6 +22,12 @@
<input id="user_id_val" type="hidden" name="id"/> <input id="user_id_val" type="hidden" name="id"/>
</form> </form>
</div> </div>
<div>
<form action="delete_user.php" method="post">
<input type="button" id="delete_user" value="Löschen" class="edit" disabled="true"/>
<input type="hidden" id="id_delete" name="id"/>
</form>
</div>
<div class="table-div"> <div class="table-div">
<table id="table"> <table id="table">
<thead> <thead>