Share something new
Recent Posts
No posts yet. Be the first to share something!
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'; ?>
No posts yet. Be the first to share something!