diff options
| -rw-r--r-- | intern.gospeladlershof.de/code/proben/delete.php | 25 | ||||
| -rw-r--r-- | intern.gospeladlershof.de/index.php | 2 |
2 files changed, 27 insertions, 0 deletions
diff --git a/intern.gospeladlershof.de/code/proben/delete.php b/intern.gospeladlershof.de/code/proben/delete.php new file mode 100644 index 0000000..9c59f1b --- /dev/null +++ b/intern.gospeladlershof.de/code/proben/delete.php @@ -0,0 +1,25 @@ +<?php + +require_once __DIR__ . '/../db.php'; +require_once __DIR__ . '/../session.php'; + +$db = get_db(); + +$id = $_REQUEST["proben_id"]; + +try { + $stmt = $db->prepare("DELETE FROM proben WHERE id = :proben_id;"); + + $stmt->bindValue(":proben_id", $id); + + $stmt->execute(); +} catch ( Exception $e ) { + $_SESSION["error"] = $e->getMessage(); + error_log($e->getMessage()); +} + +if ( empty($_SESSION) || is_null($_SESSON["error"]) ) { + $_SESSION["success"] = "Probe gelöscht!"; +} +header($_SERVER["SERVER_PROTOCOL"] . " 302 Redirect"); +header("Location: /"); diff --git a/intern.gospeladlershof.de/index.php b/intern.gospeladlershof.de/index.php index d7e461b..2ec7ccb 100644 --- a/intern.gospeladlershof.de/index.php +++ b/intern.gospeladlershof.de/index.php @@ -116,6 +116,7 @@ if ( isset($_SESSION["error"]) && ! is_null($_SESSION["error"]) ) { <th>Termin</th> <th>Uhrzeit</th> <th>Aktualisieren</th> + <th>Löschen</th> </tr> </thead> <tbody> @@ -133,6 +134,7 @@ if ( isset($_SESSION["error"]) && ! is_null($_SESSION["error"]) ) { <td><?php echo htmlentities($item["termin"]); ?></td> <td><?php echo htmlentities($item["uhrzeit"]); ?></td> <td><a href="update_proben.php?id=<?php echo htmlentities($item["id"]);?>" title="Den Eintrag ändern"><span class="glyphicon glyphicon-pencil"></span></a></td> + <td><a href="code/proben/delete.php?id=<?php echo htmlentities($item["id"]);?>" title="Den Termin löschen"><span style="color: red;" class="glyphicon glyphicon-remove"></span></a></td> </tr> <?php } |
