delete stations
This commit is contained in:
20
app/public/delete_station.php
Normal file
20
app/public/delete_station.php
Normal 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;
|
||||
?>
|
||||
@@ -13,6 +13,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
$con = null;
|
||||
|
||||
header("Location: mannschaft.php");
|
||||
die;
|
||||
?>
|
||||
@@ -15,6 +15,7 @@ function init() {
|
||||
station_edit_button();
|
||||
team_edit_button();
|
||||
team_delete_button();
|
||||
station_delete_button();
|
||||
}
|
||||
|
||||
var selected = null;
|
||||
@@ -109,4 +110,18 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,12 @@
|
||||
<input type="hidden" id="s_id" name="s_id"/>
|
||||
</form>
|
||||
</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">
|
||||
<table id="table">
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user