; $tour = $tour ? "?tour=$tour" : ''; header('Location: http://' . getSite( $site ) . "/linkcode/$user$site:$zone$tour"); function getSite( $site_code = NULL) { //find site by code $r = mysql_query("SELECT site_main_url FROM sites WHERE site_code = '$site_code'"); if( FALSE === ( $r = mysql_fetch_object( $r ) ) ) exit("Wrong site code!"); return $r->site_main_url; }