Comment by dlk on 2005-02-18
isn't there another possibility? i can't use header ():
error:
Cannot modify header information - headers already sent by (output started at
Comment by veto on 2005-02-28
You can always use header() ...just don't print anything on the page before the redirect. Why would you want to display anything on the page when it's redirecting?
Comment by scott on 2005-03-05
Yes, something else is needed. I'm detecting browsers in an PHP page, then need to redirect to another page if browser=X ... I get the same message as 'dlk' (i.e. Warning: Cannot modify header information - headers already sent by (output started at..."
Comment by scott on 2005-03-06
Aha ... the only thing needed is more PHP experience!
***IMPORTANT***
Not only must 'you call this function before ANY output', but it MUST go at the very top of the (in my case) HTML file. Before, even, the tag.
Do that and it works as advertised.
Comment by scott on 2005-03-06
CORRECTION: Should read "Before, even, the "HTML" tag.
Comment by teddy on 2005-04-01
if i put session_start() on the top of the page then why cant i using header() in the subsequent code, say at the end of the code. HELP ME!!!
Comment by chris on 2005-04-18
Here is what I found that works as a comment on the PHP manual under headers_sent() function:
\r\n";
}
}
?>
Comment by eswar on 2005-04-20
when i use header() to redirect a url , i am getting an error message. How to solve it. please help me in this situation
Comment by Jonny on 2005-04-30
ive already used a header/redirect script is there another one i could use in the same file?
Comment by Yohan on 2005-07-05
how to specify the target if we're using framed pages?
can anyone help?
Comment by ghostwind on 2005-07-31
\"You can always use header() ...just don\'t print anything on the page before the redirect. Why would you want to display anything on the page when it\'s redirecting?\"
You need to use output buffering. In effect, what you are doing when you run the redirect through php, you are sending information after the header info has already been sent to the server creating the error message. Regardless of where the script is on the page, you should use \"ob_start()\" at the beggining of redirect, and \"ob_end_flush()\" at the end
Comment by Eugene on 2005-08-02
Why would you want to display anything on the page when it\'s redirecting?\" You wouldnt but what if someone was doing a hit counter. To count how many times that url was being visited?
Comment by Paul on 2005-08-12
THis info is just what i needed
Comment by mendy on 2005-08-24
I'm trying to run this code & the first statement is not working. PLZ check it for me.
if(($_POST["use"] == "$user") && ($_POST["passwd"] == "$passwd"))
{
$url = '/ediover.php';
header("Location:$url");
}
It doesn't redirect the page. It gives me thi warning :-Warning: Cannot modify header information - headers already sent by (output started at C:\apache2triad\htdocs\itd\login.php:14) in C:\apache2triad\htdocs\itd\login.php on line 35
Comment by Okuwa Nwanze on 2005-12-02
Warning: Cannot modify header information - headers already sent by (output started at
Comment by xan on 2005-12-09
i want to check the user name and password before i redirect .. what shall i do ...
Comment by Harish on 2007-03-07
you must call this function before you output anything, otherwise the server automatically generates a header for you and you'll receive a "Cannot modify header information - headers already sent" error message. You can't even output a space.
THATS TRUE.. EXACTLY ITS ONE FROM THOUSAND..
Comment by Dilz on 2007-07-21
Wow Super Please Give some more info about php tips www.superfilez.com
Comment by Mohsin Raza on 2007-09-29
Its very impressive way, ive already used a header/redirect script is there another one i could use in the same file?
Comment by maya on 2010-01-12
It is of course for you to get aion power leveling and aion kinah to join a company that has some really good service addresses for you to choose the cheap aion power leveling and fast aion kinah delivery. One thing to note is that there are many cheap wow power leveling and wow gold companies allow you to actually choose some really great wow power leveling and wow gold service.
Comment by john on 2010-04-05
How can we redirect as in a response redirect after submitting a form?
Comment by Dave on 2010-08-10
What if there are no spaces OR output, but the error occures anyway, as in the example below?
$word = $_GET['word'];
$array = array("word1", "word2", "word3");
if (in_array($word, $array)) {
header('Location: index2.php');
}
Comment by Dave on 2010-08-10
Nevermind. I created a new PHP file (everything exactly the same) and it works perfectly. I have done these rediercts a billion times and only had a problem the first time that I tried it. So, I have no idea why it did not work this time. The original file still does not redirect, even though it is the same as the new one. Go figure. Thanks anyway. :)
Comment by Francis Ndungu on 2012-01-17
Yes one should write the php redirecting script on the first line before anything is sent to server e.g
on the first line
Also see my article on Installing PHP and MySql On windows Xp running IIs on http://frankwiz.eu.pn/articles.php and also see where you can get free webhosting to test PHP and MySql for free in the same article
Comment by qammar on 2012-01-24
very help full tip
qammar
http://www.pkshops.com
Comment by Gildas on 2011-08-17
I'm so glad I found my soluiotn online.
Comment by discount Michael Jordan Shoes on 2010-09-17
Air Jordan Shoes are always so attractive, good quality can ensure the wearer's feet, not only that, the Michael Jordan Shoes has become a fashion, many young people are very fanatical Air Jordan. High price so many people can realize their dreams. Well now, our products directly from third-party products, so we can provide cheap Jordan Basketball Shoes and New Jordan Shoes, high quality, excellent service, come on, give yourself a choice.
We offerAir Jordan 1, Air Jordan 2, Air Jordan 3,Air Jordan 4, Air Jordan 5, Air Jordan 6, Air Jordan 7, Air Jordan 8, Air Jordan 9, Air Jordan 10, Air Jordan 11 and so on!
|