exec("SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci"); } catch (PDOException $e) { die("Błąd połączenia z bazą danych: " . $e->getMessage()); } $stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([$_SESSION['user_id']]); $userData = $stmt->fetch(PDO::FETCH_ASSOC); $phoneCountryOptions = [ '+48' => 'Polska (+48)', '+44' => 'Wielka Brytania (+44)', '+49' => 'Niemcy (+49)', '+33' => 'Francja (+33)', '+34' => 'Hiszpania (+34)', '+39' => 'Włochy (+39)', '+31' => 'Holandia (+31)', '+420' => 'Czechy (+420)', '+421' => 'Słowacja (+421)', '+1' => 'USA/Kanada (+1)' ]; $storedPhoneNumber = trim((string)($userData['phone_number'] ?? '')); $currentPhoneCountryCode = ''; $currentPhoneNumber = $storedPhoneNumber; if ($storedPhoneNumber !== '' && preg_match('/^(\+\d{1,4})\s*(.*)$/', $storedPhoneNumber, $matches)) { $parsedCode = trim((string)$matches[1]); $parsedLocal = trim((string)$matches[2]); if (array_key_exists($parsedCode, $phoneCountryOptions)) { $currentPhoneCountryCode = $parsedCode; $currentPhoneNumber = $parsedLocal; } } if (!$userData) { session_destroy(); header('Location: /login/'); exit(); } ?>