prepare("SELECT client_id FROM users WHERE id = ?"); $stmt->execute([$user_id]); $client_id = $stmt->fetchColumn(); if ($client_id) { $stmt = db()->prepare("UPDATE clients SET language = ? WHERE id = ?"); $stmt->execute([$new_lang, $client_id]); } } $uri = $_SERVER['REQUEST_URI']; $url_parts = parse_url($uri); $path = $url_parts['path']; $query = []; if (isset($url_parts['query'])) { parse_str($url_parts['query'], $query); unset($query['lang']); } $new_url = $path; if (!empty($query)) { $new_url .= '?' . http_build_query($query); } header("Location: " . $new_url); exit; } // Redirect handlowiec from client area to admin dashboard if (is_logged_in() && get_user_role() === 'handlowiec' && strpos($_SERVER['PHP_SELF'], '/admin/') === false) { header('Location: /admin/orders.php'); exit(); }