Problem with redirect
| From: | Bunmi Akinmboni | Date: | Thu, 17 Mar 2005 04:57:52 +0000 |
| Subject: | Problem with redirect | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-25764@lists.php.net to get a copy of this message | ||
I develop under windows. Why will my redirect be giving this error:
Warning: Cannot modify header information - headers already sent by
(output started at
c:\inetpub\wwwroot\nacd\includes\functions.inc.php:67) in
c:\inetpub\wwwroot\nacd\includes\functions.inc.php on line 232
My code is:
$insertGoTo = "Login.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
KT_redir($insertGoTo);
function KT_redir($url) {
global $HTTP_SERVER_VARS;
$protocol = "http://";
$server_name = $HTTP_SERVER_VARS["HTTP_HOST"];
if ($server_name != '') {
$protocol = "http://";;
if (isset($HTTP_SERVER_VARS['HTTPS']) && ($HTTP_SERVER_VARS['HTTPS']
== "on")) {
$protocol = "https://";
}
if (preg_match("#^/#", $url)) {
$url = $protocol.$server_name.$url;
} else if (!preg_match("#^[a-z]+://#", $url)) {
$url = $protocol.$server_name.(preg_replace("#/[^/]*$#", "/",
$HTTP_SERVER_VARS["PHP_SELF"])).$url;
}
header("Location: ".$url);
}
exit;
}