prepare("INSERT INTO todos (title) VALUES (?)"); $stmt->execute([$_POST['title']]); } break; case 'toggle': if (isset($_POST['id'])) { $stmt = $pdo->prepare("UPDATE todos SET status = IF(status = 'completed', 'pending', 'completed') WHERE id = ?"); $stmt->execute([$_POST['id']]); } break; case 'delete': if (isset($_POST['id'])) { $stmt = $pdo->prepare("DELETE FROM todos WHERE id = ?"); $stmt->execute([$_POST['id']]); } break; } } catch (PDOException $e) { // For simplicity, we die on DB error during POST die("Database error: " . $e->getMessage()); } // Redirect to the page the user was on $redirect_url = $_SERVER['HTTP_REFERER'] ?? 'index.php'; header("Location: " . $redirect_url); exit; } // Fetch active todos for the main page try { $todos = $pdo->query("SELECT * FROM todos WHERE status = 'pending' ORDER BY created_at DESC")->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { die("Не удалось загрузить задачи: " . $e->getMessage()); } ?> Активные задачи // Super Todo List 2056

Super Todo List // 2056