diff --git a/admin/blog.php b/admin/blog.php
new file mode 100644
index 0000000..9090b38
--- /dev/null
+++ b/admin/blog.php
@@ -0,0 +1,97 @@
+prepare("SELECT id FROM blog_posts WHERE slug = ?");
+ $stmt->execute([$slug]);
+ $i = 1;
+ $original_slug = $slug;
+ while($stmt->fetch()){
+ $slug = $original_slug . '-' . $i++;
+ $stmt->execute([$slug]);
+ }
+
+ $stmt = $pdo->prepare("INSERT INTO blog_posts (title, content, slug) VALUES (?, ?, ?)");
+ $stmt->execute([$title, $content, $slug]);
+ header('Location: blog.php');
+ exit();
+}
+
+// Fetch all blog posts
+$pdo = db();
+$stmt = $pdo->query("SELECT * FROM blog_posts ORDER BY created_at DESC");
+$posts = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+?>
+
+
+
+
+
+ Manage Blog
+
+
+
+
+
+
+
Manage Blog
+
+
Add New Post
+
+
+
Existing Posts
+
+
+
+ | Title |
+ Created At |
+ Actions |
+
+
+
+
+
+ |
+ |
+
+ Edit
+ Delete
+ |
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/dashboard.php b/admin/dashboard.php
new file mode 100644
index 0000000..723cea4
--- /dev/null
+++ b/admin/dashboard.php
@@ -0,0 +1,172 @@
+prepare($sql);
+ $stmt->execute(['key' => $key, 'value' => $value]);
+}
+
+if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ try {
+ if (isset($_POST['hero_title'])) {
+ update_content($pdo, 'hero_title', $_POST['hero_title']);
+ update_content($pdo, 'hero_subtitle', $_POST['hero_subtitle']);
+ $message = 'Hero section updated successfully!
';
+ }
+
+ if (isset($_POST['about_me_content'])) {
+ update_content($pdo, 'about_me', $_POST['about_me_content']);
+ $message = '\"About Me\" section updated successfully!
';
+ }
+
+ if (isset($_POST['add_portfolio_item'])) {
+ $sql = "INSERT INTO portfolio_items (title, description, image_url, project_url) VALUES (:title, :description, :image_url, :project_url)";
+ $stmt = $pdo->prepare($sql);
+ $stmt->execute([
+ 'title' => $_POST['title'],
+ 'description' => $_POST['description'],
+ 'image_url' => $_POST['image_url'],
+ 'project_url' => $_POST['project_url']
+ ]);
+ $message = 'Portfolio item added successfully!
';
+ }
+
+ if (isset($_POST['delete_portfolio_item'])) {
+ $sql = "DELETE FROM portfolio_items WHERE id = :id";
+ $stmt = $pdo->prepare($sql);
+ $stmt->execute(['id' => $_POST['item_id']]);
+ $message = 'Portfolio item deleted successfully!
';
+ }
+
+ } catch (PDOException $e) {
+ $message = 'Error updating content: ' . $e->getMessage() . '
';
+ }
+}
+
+// Fetch site content
+$content = [];
+try {
+ $stmt = $pdo->query("SELECT section_key, section_value FROM site_content");
+ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $content[$row['section_key']] = $row['section_value'];
+ }
+} catch (PDOException $e) {
+ $message = 'Error fetching site content: ' . $e->getMessage() . '
';
+}
+
+// Fetch portfolio items
+$portfolio_items = [];
+try {
+ $portfolio_items = $pdo->query("SELECT * FROM portfolio_items ORDER BY sort_order ASC, created_at DESC")->fetchAll(PDO::FETCH_ASSOC);
+} catch (PDOException $e) {
+ $message = 'Error fetching portfolio items: ' . $e->getMessage() . '
';
+}
+
+
+$hero_title = $content['hero_title'] ?? '';
+$hero_subtitle = $content['hero_subtitle'] ?? '';
+$about_me_content = $content['about_me'] ?? '';
+
+?>
+
+
+
+
+
+
+
+
Manage Portfolio
+
+
+
+
+
Existing Items
+
+
+
+ | Image |
+ Title |
+ Action |
+
+
+
+
+ | No portfolio items yet. |
+
+
+
+ ; ?>) |
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
Welcome, !
+
You can manage your website content from here.
+
+
+
+
+
+
diff --git a/admin/delete_blog.php b/admin/delete_blog.php
new file mode 100644
index 0000000..99a5455
--- /dev/null
+++ b/admin/delete_blog.php
@@ -0,0 +1,21 @@
+prepare("DELETE FROM blog_posts WHERE id = ?");
+$stmt->execute([$id]);
+
+header('Location: blog.php');
+exit();
diff --git a/admin/delete_portfolio.php b/admin/delete_portfolio.php
new file mode 100644
index 0000000..d028b2a
--- /dev/null
+++ b/admin/delete_portfolio.php
@@ -0,0 +1,21 @@
+prepare("DELETE FROM portfolio_items WHERE id = ?");
+$stmt->execute([$id]);
+
+header('Location: portfolio.php');
+exit();
diff --git a/admin/edit_blog.php b/admin/edit_blog.php
new file mode 100644
index 0000000..0207c88
--- /dev/null
+++ b/admin/edit_blog.php
@@ -0,0 +1,84 @@
+prepare("SELECT id FROM blog_posts WHERE slug = ? AND id != ?");
+ $stmt->execute([$slug, $id]);
+ $i = 1;
+ $original_slug = $slug;
+ while($stmt->fetch()){
+ $slug = $original_slug . '-' . $i++;
+ $stmt->execute([$slug, $id]);
+ }
+
+ $stmt = $pdo->prepare("UPDATE blog_posts SET title = ?, content = ?, slug = ? WHERE id = ?");
+ $stmt->execute([$title, $content, $slug, $id]);
+ header('Location: blog.php');
+ exit();
+}
+
+// Fetch the blog post
+$stmt = $pdo->prepare("SELECT * FROM blog_posts WHERE id = ?");
+$stmt->execute([$id]);
+$post = $stmt->fetch(PDO::FETCH_ASSOC);
+
+if (!$post) {
+ header('Location: blog.php');
+ exit();
+}
+?>
+
+
+
+
+
+ Edit Blog Post
+
+
+
+
+
+
+
Edit Blog Post
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/edit_portfolio.php b/admin/edit_portfolio.php
new file mode 100644
index 0000000..dc5402f
--- /dev/null
+++ b/admin/edit_portfolio.php
@@ -0,0 +1,95 @@
+prepare("UPDATE portfolio_items SET title = ?, description = ?, image_url = ? WHERE id = ?");
+ $stmt->execute([$title, $description, $image_url, $id]);
+ header('Location: portfolio.php');
+ exit();
+ }
+}
+
+// Fetch the portfolio item
+$stmt = $pdo->prepare("SELECT * FROM portfolio_items WHERE id = ?");
+$stmt->execute([$id]);
+$item = $stmt->fetch(PDO::FETCH_ASSOC);
+
+if (!$item) {
+ header('Location: portfolio.php');
+ exit();
+}
+?>
+
+
+
+
+
+ Edit Portfolio Item
+
+
+
+
+
+
+
Edit Portfolio Item
+
+
+
+
+
+
+
+
+
+
+
diff --git a/admin/footer.php b/admin/footer.php
new file mode 100644
index 0000000..691287b
--- /dev/null
+++ b/admin/footer.php
@@ -0,0 +1,2 @@
+