| 123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- session_start();
- if (!isset($_SESSION['user_id'])) {
- // Redirect to login/register if not logged in
- header('Location: register.php');
- exit;
- }
- // Fetch username for display
- $pdo = new PDO('mysql:host=sql101.infinityfree.com;dbname=if0_39567875_nex', 'if0_39567875', 'PIvOR9WViHm'); // Update credentials
- $stmt = $pdo->prepare("SELECT username FROM users WHERE id = ?");
- $stmt->execute([$_SESSION['user_id']]);
- $user = $stmt->fetch();
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Nexus</title>
- <link rel="stylesheet" href="styles.css">
- </head>
- <body>
- <div class="container">
- <h2>Welcome, <?php echo htmlspecialchars($user['username']); ?>! <a href="api/logout.php">Logout</a></h2>
- <div id="chat-window"></div>
- <form id="chat-form">
- <input type="text" name="message" placeholder="Type your message..." required>
- <input type="file" name="attachment">
- <button type="submit">Send</button>
- </form>
- <button id="refresh-btn">Refresh Chat</button>
- </div>
- <script src="script.js"></script>
- </body>
- </html>
|