35429-vm/add_ticket.php
2025-11-02 20:12:50 +00:00

28 lines
856 B
PHP

<?php
require_once 'db/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$title = $_POST['title'] ?? null;
$description = $_POST['description'] ?? null;
$status = $_POST['status'] ?? 'Open';
$priority = $_POST['priority'] ?? 'Medium';
if ($title) {
try {
$pdo = db();
$sql = "INSERT INTO tickets (title, description, status, priority) VALUES (?, ?, ?, ?)";
$stmt = $pdo->prepare($sql);
$stmt->execute([$title, $description, $status, $priority]);
header("Location: tickets.php?success=1");
exit();
} catch (PDOException $e) {
header("Location: tickets.php?error=" . urlencode($e->getMessage()));
exit();
}
} else {
header("Location: tickets.php?error=invalid_input");
exit();
}
}
?>