Re: header() problem
| From: | Ray | Date: | Sat, 29 Dec 2001 18:30:59 +0000 |
| Subject: | Re: header() problem | ||
| References: | 1 2 3 4 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-11209@lists.php.net to get a copy of this message | ||
I use PHP 4.06, Using Apache, and running under windows.
This code is tested and works using IE;
header ("Location: http://localhost/test/secure_1.php");
exit;
Like the other message(s) said, you must NOT output anything before you send
a header. If you do however, you will get a runtime error and it will be
displayed on the webpage (unless you supressed the errors).
But this will redirect you to another webpage. Exit is required, so this
script stops execution. Die might work as well, but that quits the script.
Exit simply exists the current function, but the rest of the program/script
(if inside a function) will contune to run.
--
Ray
rgaylog@rogers.com
"Christoph Grottolo" <christoph.grottolo@gmx.net> wrote in message
news:20011229113357.43814.qmail@pb1.pair.com...
> Make sure there is no sign before you start the file with '<?php...'.
>
> Every sign (char, space, newline) outside the php script is interpreted as
> part of the page and therefore sent to the browser. Header information has
> to be sent before. If not, it won't be transmitted. See also
> http://www.php.net/manual/en/function.header.php for this (very
> common)
> error.
>
> Christoph
>
> "Jukka Pakkanen" <jukka.pakkanen@qnet.fi> schrieb im Newsbeitrag
> news:000b01c18fbc$71813000$12aba5c3@qnet.fi...
> The test.php file only has:
>
> <?php
>
> header("Location: http://www.qnet.fi\r\n\n");
> exit();
>
> ?>
>
> Result is a blank page, source code:
>
> [!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"]
> [HTML][HEAD]
> [META http-equiv=Content-Type content="text/html;
> charset=windows-1252"][/HEAD]
> [BODY][/BODY][/HTML]
>
> The webserver is Website Pro 3. I've tried IE 5.5sp2 and IE 6. You can
try
> it at http://www.karting.fi/test.php
>
> Otherwise PHP works ok in the server.
>
>
> > At 05:44 PM 12/28/2001 +0200, Jukka Pakkanen wrote:
> > >Thanks Mike, but still no luck. Nothing happens. No errors, no
redirects,
> > >no nothing :(
> >
> > Hmmm.. have you tried just making a blank page with this code? If so,
> what
> > shows up in the browser? A blank page? View the source, what does it
> show?
> >
> > You're running Netscape 4, is that right? Have you tried it in another
> > browser?
> >
> > -Mike
> >
> >
> > > > At 02:46 PM 12/28/2001 +0200, you wrote:
> > > > >Running NT4sp6a and PHP4.1.0.
> > > > >
> > > > >I try to redirect the browser to a new location [<?
header("Location:
> > > > >http://www.qnet.fi"); ?>], but
> > > > >nothing happens in the browser.
There
> > > are no
> > > > >extra spaces, CR's, LF's or anything, and output_buffers are on in
> the
> > > > >php.ini.
> > > > >
> > > > >Any ideas??
> > > > >
> > > > >I run in to this problem when trying to run some software which is
> > > known to
> > > > >work, and now I tested it with a simple test.php (above). Don't
work.
> > > >
> > > > Try:
> > > > <?php
> > > >
> > > > header("Location:
> > > > http://www.qnet.fi/\r\n\n");
> > > > exit();
> > > >
> > > > ?>
> > > >
> > > >
> > > >
> > >
> > >
> > >--
> > >PHP Windows Mailing List (http://www.php.net/)
> > >To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> > >For additional commands, e-mail: php-windows-help@lists.php.net
> > >To contact the list administrators, e-mail:
php-list-admin@lists.php.net
> >
> > -=- Mike Flynn - Burlington, VT -=-
> > mike@mikeflynn.net http://www.mikeflynn.net/ * Give
> > blood *
> > ...maintaining lawns, watching televised sports, birthing
> > children, listening to Top 40 music, and collecting
> > stuffed animals...
> >
> >
> >
>
>
>