Re: Opening another page in code (PROPOSED FAQ)
| From: | Brian White | Date: | Thu, 26 Jul 2001 00:08:14 +0000 |
| Subject: | Re: Opening another page in code (PROPOSED FAQ) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-59643@lists.php.net to get a copy of this message | ||
I have seen this question alot recently. Maybe it is time for an FAQ. Maybe somebody
else would like to have an attempt at wording this better:
Q: (7.15?) I want to use the "header" function to do something like a redirect, but I keep
getting messages about the headers having already been sent.A: The headers are sent to the browser just before the first piece of content
is sent. Content is
a) Any text generated by a PHP output function ( such as "print" or "echo" )
b) Any text before, after or between the "<?php ... ?>" blocks.
The usual reason to get this error message, when you would swear blind you
aren't outputting anything yet, is white space before outside of the code
blocks. Eg:
<?php require("user_logging.inc") ?>
<?php header ("Content-Type: audio/x-pn-realaudio"); ?>
// Broken, Note the blank lines above will be treated as
// content and cause the headers to be sent
If you changed the above code to
<?php
require("user_logging.inc");
header ("Content-Type: audio/x-pn-realaudio");
?>
and still got the error, then that probably means extra white-space
somewhere in "user_logging.inc"
At 07:30 25/07/2001 -0600, Nelson Goforth wrote:
This seems simple, but for some reason I can't find what I'm looking for in books or the archive. Might just be looking for the wrong words.
I just want to open another page, sending some parameters, at a point in a script - without the user clicking on anything (I can do this in a form - I want to do it WITHOUT the form).
Like: if($test) {
GO_TO_PAGE (http://www.site.dom/page.php?id=838383);
}
Except with code that actually works, of course.
I tried "header (Location:...)" but got an error message that I can't add to the headers.
What have I missed?
Thanks,
Nelson
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net
-------------------------
Brian White
Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy
Phone: +612-93197901
Web: http://www.steptwo.com.au/
Email: bwhite@steptwo.com.au