header problem
| From: | A.a.k | Date: | Thu, 10 Sep 2009 06:27:29 +0000 |
| Subject: | header problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-297853@lists.php.net to get a copy of this message | ||
hello
I recentrly uploaded my project from localhost to a hosting and found many errors and warnings which didnt have in local. one of the most annoying one is header('Location xxx').
I have used header to redirect users from pages, and kinda used it alot. i know about the whitespace causing warning, but most of the pages i'm sending users got html and php mixed so i'm confused about how to remove whitespace in a html/php file. the error is :
Warning: Cannot modify header information - headers already sent by ....
here is a simple example, user update page :
if($valid)
{
$msg='111';
$user->dbupdate();
header("Location: /admin/index.php?msg=$msg");
}
else
{
foreach($errors as $val)
echo '<p id="error">'.$val.'</p>';
}
and on admin index i get $msg and display it.
<html>
......
//lots of stuff
<?php
$msg = $_GET['msg'];
switch($msg){
case '111' echo '<p> </p>';
break;
case '421':...
}
?>
// more html and php
how can i fix this?