1){; $pairs = explode("&", $query[1]); for ($i=0; $i < count($pairs); $i++){ // split key and value $query[$i]= explode("=", $pairs[$i]); list($key, $val) = $query[$i]; switch ($key){ case "page_id": case "cmd": case "login_msg": // do nothing on page_id, cmd and login_msg break; default: $var [$key] = $val; break; } } // end for -> no more pairs left } else { // there were no variables $page.="page_id=$to&"; } /****************************************************************************** * get the variables of the query string *****************************************************************************/ // read the variables of the link $query = ""; $pairs = explode("&", $_SERVER["QUERY_STRING"]); for ($i=0; $i < count($pairs); $i++){ $query[$i]= explode("=", $pairs[$i]); list($key, $val) = $query[$i]; switch ($key){ case "eng": case "page_id": case "to": // do nothing on to, page_id and eng break; default: $var [$key] = $val; break; } } /****************************************************************************** * build link *****************************************************************************/ $page .= "page_id=" . $to . "&"; while (list($key, $val)= each($var)){ $page .= "$key=$val&"; } $page = substr($page, 0, strlen($page)-1); header("Location: $page" . ($error ? "&error=link" : "") ); ?>