diff --git a/active.php b/active.php
new file mode 100644
index 0000000..959667f
--- /dev/null
+++ b/active.php
@@ -0,0 +1,3 @@
+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) {
+ die("Database error: " . $e->getMessage());
+ }
+
+ header("Location: " . $_SERVER['HTTP_REFERER'] ?? 'completed.php');
+ exit;
+}
+
+// Fetch completed todos
+try {
+ $todos = $pdo->query("SELECT * FROM todos WHERE status = 'completed' ORDER BY created_at DESC")->fetchAll(PDO::FETCH_ASSOC);
+} catch (PDOException $e) {
+ die("Не удалось загрузить задачи: " . $e->getMessage());
+}
+?>
+
+
+
+
+
+ Выполненные задачи // Super Todo List 2056
+
+
+
+
+
+
+
+
+
Super Todo List // 2056
+
+
+
+
+
+
+ - Нет выполненных задач.
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/db/migrate.php b/db/migrate.php
new file mode 100644
index 0000000..24ecef7
--- /dev/null
+++ b/db/migrate.php
@@ -0,0 +1,14 @@
+exec($sql);
+ echo "Migration applied successfully!\n";
+} catch (PDOException $e) {
+ die("Migration failed: " . $e->getMessage() . "\n");
+}
+
diff --git a/db/migrations/001_create_todos_table.sql b/db/migrations/001_create_todos_table.sql
new file mode 100644
index 0000000..213fc50
--- /dev/null
+++ b/db/migrations/001_create_todos_table.sql
@@ -0,0 +1,6 @@
+CREATE TABLE IF NOT EXISTS `todos` (
+ `id` INT AUTO_INCREMENT PRIMARY KEY,
+ `title` VARCHAR(255) NOT NULL,
+ `status` ENUM('pending', 'completed') NOT NULL DEFAULT 'pending',
+ `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
diff --git a/images/eva-background.jpeg b/images/eva-background.jpeg
new file mode 100644
index 0000000..6874fc8
Binary files /dev/null and b/images/eva-background.jpeg differ
diff --git a/index.php b/index.php
index f7ae6b8..38336e6 100644
--- a/index.php
+++ b/index.php
@@ -1,103 +1,304 @@
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());
+}
?>
-
-
+
+
-
-
- New Style
-
-
-
-
+
+
+ Активные задачи // Super Todo List 2056
+
+
+
+
+
-
-
-
Welcome!
-
Your project is ready to conquer the peaks.
-
PHP version: = htmlspecialchars($phpVersion) ?>
+
+
Super Todo List // 2056
+
+
+
+
+
+
+
+
+ - Активных задач нет.
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
\ No newline at end of file