prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([$_SESSION['user_id']]); $user = $stmt->fetch(); $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; // Fetch Matches for Founders $matches = []; if ($user['role'] === 'founder') { $stmt = db()->prepare(" SELECT m.*, u.full_name as match_name, u.id as match_id, u.university, u.degree_program FROM matches m JOIN users u ON (m.user1_id = u.id OR m.user2_id = u.id) WHERE (m.user1_id = ? OR m.user2_id = ?) AND u.id != ? "); $stmt->execute([$_SESSION['user_id'], $_SESSION['user_id'], $_SESSION['user_id']]); $matches = $stmt->fetchAll(); } // Fetch Conversations $stmt = db()->prepare(" SELECT DISTINCT u.id as other_user_id, u.full_name as other_user_name, u.role as other_role FROM messages m JOIN users u ON (m.sender_id = u.id OR m.receiver_id = u.id) WHERE (m.sender_id = ? OR m.receiver_id = ?) AND u.id != ? "); $stmt->execute([$_SESSION['user_id'], $_SESSION['user_id'], $_SESSION['user_id']]); $conversations = $stmt->fetchAll(); $active_chat_id = isset($_GET['chat_with']) ? (int)$_GET['chat_with'] : null; $active_chat_user = null; $chat_messages = []; if ($active_chat_id) { $stmt = db()->prepare("SELECT id, full_name, role FROM users WHERE id = ?"); $stmt->execute([$active_chat_id]); $active_chat_user = $stmt->fetch(); if ($active_chat_user) { $stmt = db()->prepare(" SELECT * FROM messages WHERE (sender_id = ? AND receiver_id = ?) OR (sender_id = ? AND receiver_id = ?) ORDER BY created_at ASC "); $stmt->execute([$_SESSION['user_id'], $active_chat_id, $active_chat_id, $_SESSION['user_id']]); $chat_messages = $stmt->fetchAll(); } } // Handle sending message if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['content']) && $active_chat_id) { $content = trim($_POST['content']); if (!empty($content)) { $stmt = db()->prepare("INSERT INTO messages (sender_id, receiver_id, content) VALUES (?, ?, ?)"); $stmt->execute([$_SESSION['user_id'], $active_chat_id, $content]); header("Location: messages.php?chat_with=$active_chat_id"); exit; } } ?> Messages — <?= htmlspecialchars($platformName) ?>
Log Out
Conversations
New Matches
New Match! Say hi!
Recent Chats
No active chats.

This is the start of your conversation with .

Select a conversation to start chatting

Find co-founders in the matching section.