By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,639 Members | 2,000 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,639 IT Pros & Developers. It's quick & easy.

Warning: Cannot modify header information - headers already sent

100+
P: 150
I'm having problem with header redirection that is my code:
[PHP]<?php
header("location:Redirecting.php");
exit;
?>
//Then the HTML
[/PHP]

It give me an error

[HTML]Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\example\Signup.php:1) in C:\wamp\www\example\Signup.php on line 2[/HTML]
Sep 24 '07 #1
Share this Question
Share on Google+
2 Replies


Atli
Expert 5K+
P: 5,058
Hi.

The header() function MUST be called before you send anything to the browser... Even a white-space before the <?php tag will cause the error you are getting.

For example:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. # This will not work, giving you the error you described.
  3. echo "You will be redirected in 3 seconds...";
  4. header("Refresh: 3; url=http://www.google.com");
  5. ?>
  6.  
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. # This, however, will work.
  3. header("Refresh: 3; url=http://www.google.com");
  4. echo "You will be redirected in 3 seconds...";
  5. ?>
  6.  
Sep 24 '07 #2

pbmods
Expert 5K+
P: 5,821
Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).
Sep 25 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.