prepare("SELECT id FROM sessions WHERE session_code = ?"); $stmt->execute([$session_code]); if ($stmt->rowCount() === 0) { $is_unique = true; } } // Insert the new session $stmt = $pdo->prepare("INSERT INTO sessions (session_code) VALUES (?)"); $stmt->execute([$session_code]); $session_id = $pdo->lastInsertId(); // Redirect to the session page header("Location: session.php?id=" . $session_id); exit();