diff --git a/admin/dashboard.php b/admin/dashboard.php new file mode 100644 index 0000000..4d49045 --- /dev/null +++ b/admin/dashboard.php @@ -0,0 +1,125 @@ +exec("CREATE TABLE IF NOT EXISTS stations ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + url VARCHAR(255) NOT NULL, + logo_url VARCHAR(255) + )"); + + // Handle form submissions for add/edit/delete + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if (isset($_POST['add'])) { + $stmt = $pdo->prepare("INSERT INTO stations (name, url, logo_url) VALUES (?, ?, ?)"); + $stmt->execute([$_POST['name'], $_POST['url'], $_POST['logo_url']]); + } elseif (isset($_POST['edit'])) { + $stmt = $pdo->prepare("UPDATE stations SET name = ?, url = ?, logo_url = ? WHERE id = ?"); + $stmt->execute([$_POST['name'], $_POST['url'], $_POST['logo_url'], $_POST['id']]); + } elseif (isset($_POST['delete'])) { + $stmt = $pdo->prepare("DELETE FROM stations WHERE id = ?"); + $stmt->execute([$_POST['id']]); + } + header("Location: dashboard.php"); + exit; + } + + // Fetch all stations + $stations = $pdo->query("SELECT * FROM stations ORDER BY name")->fetchAll(); + +} catch (PDOException $e) { + $error = "Database error: " . $e->getMessage(); +} + +?> + + +
+ + +| Name | +Stream URL | +Logo URL | +Actions | +
|---|---|---|---|
| No stations found. | |||