Löschen von Themen und Fächern eingebaut
This commit is contained in:
@@ -50,6 +50,10 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$errors["icon"] = "Bitte geben Sie ein Icon an.";
|
||||
}
|
||||
|
||||
if(!isset($_POST['submit']) || !($_POST['submit'] == "Speichern" || $_POST['submit'] == "Fach löschen")) {
|
||||
$errors["submit"] = "Ungültig abgeschickt!";
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$newSubject = false;
|
||||
if(isset($allSubjects[$_POST['id']])) {
|
||||
@@ -65,11 +69,15 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
if(!$newSubject) {
|
||||
$errors["error"] = "Fehler beim Speichern des Faches.";
|
||||
} else {
|
||||
$newSubject->save();
|
||||
header("Location: " . "subject.php?subject=" . $newSubject->getId());
|
||||
if($_POST['submit'] == "Fach löschen") {
|
||||
$newSubject->delete();
|
||||
header("Location: " . "index.php");
|
||||
} else {
|
||||
$newSubject->save();
|
||||
header("Location: " . "subject.php?subject=" . $newSubject->getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -184,16 +192,13 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-8 flex justify-end gap-3">
|
||||
<button type="button" onclick="closeModal()"
|
||||
class="px-6 py-3 text-gray-600 hover:text-gray-800 text-lg">
|
||||
Abbrechen
|
||||
</button>
|
||||
<button type="submit"
|
||||
class="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 text-lg">
|
||||
Speichern
|
||||
</button>
|
||||
<div class="flow-root mt-8 gap-4">
|
||||
<input type="submit" value="Fach löschen" name="submit"
|
||||
class="float-left px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-gray-200">
|
||||
<input type="submit" value="Speichern" name="submit"
|
||||
class="float-right px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
|
||||
<input type="button" value="Abbrechen" onclick="history.back()"
|
||||
class="float-right mx-2 px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user