diff --git a/assets/css/styles.css b/assets/css/styles.css
index ee81812..6ba5f6f 100644
--- a/assets/css/styles.css
+++ b/assets/css/styles.css
@@ -337,3 +337,83 @@ tbody tr:hover {
background-color: #d4edda;
border-color: #c3e6cb;
}
+
+/* Post Section Styles */
+.post-creation-section, .feed-section {
+ background-color: #fff;
+ padding: 2rem;
+ border-radius: 0.5rem;
+ box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);
+ margin-bottom: 2rem;
+}
+
+.post-creation-section h2, .feed-section h2 {
+ margin-top: 0;
+ margin-bottom: 1.5rem;
+ font-size: 1.75rem;
+ color: #343a40;
+}
+
+.post-card {
+ border: 1px solid #e9ecef;
+ border-radius: 0.5rem;
+ padding: 1.5rem;
+ margin-bottom: 1rem;
+ background-color: #fefefe;
+}
+
+.post-card:last-child {
+ margin-bottom: 0;
+}
+
+.post-author {
+ font-size: 1rem;
+ color: #495057;
+ margin-bottom: 0.5rem;
+}
+
+.post-author strong {
+ color: #007bff;
+}
+
+.post-date {
+ font-size: 0.85rem;
+ color: #6c757d;
+ float: right;
+}
+
+.post-content {
+ font-size: 1.1rem;
+ line-height: 1.6;
+ color: #212529;
+ white-space: pre-wrap; /* Preserve whitespace and line breaks */
+}
+
+textarea#post_content {
+ width: 100%;
+ padding: 0.75rem;
+ border: 1px solid #ced4da;
+ border-radius: 0.25rem;
+ resize: vertical; /* Allow vertical resizing */
+ font-family: inherit; /* Inherit font from body */
+}
+
+button[name="new_post"] {
+ margin-top: 1rem;
+ width: auto;
+ padding: 0.75rem 2rem;
+ border-radius: 0.25rem;
+ background-color: #28a745; /* A green color for post button */
+}
+
+button[name="new_post"]:hover {
+ background-color: #218838;
+}
+
+.button-secondary {
+ background-color: #6c757d;
+}
+
+.button-secondary:hover {
+ background-color: #5a6268;
+}
diff --git a/dashboard.php b/dashboard.php
index bbe74ef..228bd17 100644
--- a/dashboard.php
+++ b/dashboard.php
@@ -1,31 +1,89 @@
prepare("INSERT INTO posts (user_id, content) VALUES (:user_id, :content)");
+ $stmt->bindParam(':user_id', $user_id, PDO::PARAM_INT);
+ $stmt->bindParam(':content', $post_content, PDO::PARAM_STR);
+ $stmt->execute();
+ $post_message = 'Your post has been shared!';
+ // Clear the post content after successful submission
+ $_POST['post_content'] = '';
+ } catch (PDOException $e) {
+ $error_message = 'Database error: ' . $e->getMessage();
+ }
+ }
+}
+
+// Fetch all posts
+$posts = [];
+try {
+ $db = db();
+ $stmt = $db->prepare("SELECT p.content, p.created_at, u.username FROM posts p JOIN users u ON p.user_id = u.id ORDER BY p.created_at DESC");
+ $stmt->execute();
+ $posts = $stmt->fetchAll(PDO::FETCH_ASSOC);
+} catch (PDOException $e) {
+ $error_message = 'Failed to load posts: ' . $e->getMessage();
+}
+
+$pageTitle = "User Dashboard - Flatlogic";
+include 'includes/header.php';
?>
-
-
-
-
-
- User Dashboard - Flatlogic
-
-
-
-
-
+
\ No newline at end of file
diff --git a/db/migrations/002_create_posts_table.sql b/db/migrations/002_create_posts_table.sql
new file mode 100644
index 0000000..bafe570
--- /dev/null
+++ b/db/migrations/002_create_posts_table.sql
@@ -0,0 +1,7 @@
+CREATE TABLE IF NOT EXISTS posts (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ user_id INT NOT NULL,
+ content TEXT NOT NULL,
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
+);
\ No newline at end of file
diff --git a/login.php b/login.php
index 9f6b7f5..af4b7a7 100644
--- a/login.php
+++ b/login.php
@@ -13,15 +13,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} else {
try {
$db = db();
- $stmt = $db->prepare("SELECT id, username, password FROM users WHERE email = :email");
+ $stmt = $db->prepare("SELECT id, username, password_hash FROM users WHERE email = :email");
$stmt->bindParam(':email', $email);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_ASSOC);
- if ($user && password_verify($password, $user['password'])) {
+ if ($user && password_verify($password, $user['password_hash'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username']; // Store username for display
- header('Location: home.php'); // Redirect to home.php
+ header('Location: dashboard.php'); // Redirect to dashboard.php
exit;
} else {
$error_message = 'Invalid email or password.';
diff --git a/register.php b/register.php
index 4cb45ef..b2dd21d 100644
--- a/register.php
+++ b/register.php
@@ -27,7 +27,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} else {
$password_hash = password_hash($password, PASSWORD_DEFAULT);
- $stmt = $db->prepare("INSERT INTO users (username, email, password) VALUES (:username, :email, :password)");
+ $stmt = $db->prepare("INSERT INTO users (username, email, password_hash) VALUES (:username, :email, :password)");
$stmt->bindParam(':username', $username);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':password', $password_hash);