delete stations

This commit is contained in:
2022-06-17 20:05:59 +02:00
parent 0f6492ec46
commit 3bea28c125
4 changed files with 43 additions and 0 deletions

View File

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

View File

@@ -13,6 +13,8 @@
} }
} }
$con = null;
header("Location: mannschaft.php"); header("Location: mannschaft.php");
die; die;
?> ?>

View File

@@ -15,6 +15,7 @@ function init() {
station_edit_button(); station_edit_button();
team_edit_button(); team_edit_button();
team_delete_button(); team_delete_button();
station_delete_button();
} }
var selected = null; var selected = null;
@@ -110,3 +111,17 @@ function team_delete_button() {
} }
} }
} }
function station_delete_button() {
var button = document.getElementById('delete_station');
if(button != null) {
button.onclick = function() {
var row = document.getElementsByClassName('selected')[0];
document.getElementById('s_id_delete').value = row.id;
let confirmAction = confirm("Wirklich löschen?");
if (confirmAction) {
this.form.submit();
}
}
}
}

View File

@@ -23,6 +23,12 @@
<input type="hidden" id="s_id" name="s_id"/> <input type="hidden" id="s_id" name="s_id"/>
</form> </form>
</div> </div>
<div>
<form action="delete_station.php" method="post">
<input id="delete_station" type="button" type="butto" value="Löschen" class="edit" disabled="true"/>
<input type="hidden" id="s_id_delete" name="s_id"/>
</form>
</div>
<div class="table-div"> <div class="table-div">
<table id="table"> <table id="table">
<thead> <thead>