base
This commit is contained in:
40
backend/save_ticket.php
Normal file
40
backend/save_ticket.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
http_response_code(405);
|
||||
echo "Method not allowed";
|
||||
exit;
|
||||
}
|
||||
|
||||
$title = trim($_POST['title'] ?? '');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$category = $_POST['category'] ?? 'Sonstiges';
|
||||
$room = trim($_POST['room'] ?? '');
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
$date = date("Y-m-d H:i:s");
|
||||
|
||||
$newTicket = [
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'category' => $category,
|
||||
'room' => $room,
|
||||
'name' => $name,
|
||||
'status' => 'To-Do',
|
||||
'date' => $date
|
||||
];
|
||||
|
||||
$ticketsPath = __DIR__ . '/tickets.json';
|
||||
$tickets = [];
|
||||
|
||||
if (file_exists($ticketsPath)) {
|
||||
$json = file_get_contents($ticketsPath);
|
||||
$tickets = json_decode($json, true);
|
||||
if (!is_array($tickets)) $tickets = [];
|
||||
}
|
||||
|
||||
$tickets[] = $newTicket;
|
||||
|
||||
file_put_contents($ticketsPath, json_encode($tickets, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), LOCK_EX);
|
||||
|
||||
// Redirect zurück ins Dashboard oder zur Hauptseite
|
||||
header('Location: ../index.html?success=1');
|
||||
exit;
|
||||
Reference in New Issue
Block a user