RE: [PHP] Header() function and redirect
| From: | Zhu George-CZZ010 | Date: | Thu, 30 Aug 2001 16:27:41 +0000 |
| Subject: | RE: [PHP] Header() function and redirect | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-65324@lists.php.net to get a copy of this message | ||
But I have to wait for the application to finish. The idea is: the application will take the file,
and convert it into PDF file (it takes more than 30 seconds generally), then display the generated
PDF file.
I am just wondering if I can use "Header()" to redirect to a general php page, then in
that page, redirect to the PDF file.
Thanks,
George
-----Original Message-----
From: * R&zE: [mailto:renze@datalink.nl]
Sent: Thursday, August 30, 2001 11:19 AM
To: Zhu George-CZZ010; php-general@lists.php.net
Subject: Re: [PHP] Header() function and redirect
<Original message>
From: Zhu George-CZZ010 <George.Z.Zhu@motorola.com>
Date: Thu, Aug 30, 2001 at 11:10:19AM -0500
Message-ID: <1FA6C7249817D4119B9800D0B73E99A6050A79FB@il02exm27.comm.mot.com>
Subject: [PHP] Header() function and redirect
>
> I am using Apache and PHP. I encountered a redirect problem in PHP, and traced it down, so, I
> generated a very short PHP page as following:
>
> <?php
> sleep(30);
> $goto =
> "http://tt.mot.com/to_pdf/pdf_tmp/test.pdf";
> Header("Location: $goto");
> exit;
> ?>
>
> If the "sleep(30);" statement is commented out, this page works fine in both
> IE4.0/IE5.0 and netscape, but if "sleep(30)" statement is in this page, it will only work
> in Netscape, but not in IE.
>
> Is there another way to do the "redirect" in PHP? or how to fix this problem (I
> can't remove the "sleep" statement because in the real program, it is a "System
> call" and will take more than 30 seconds)?
>
> Thank you very much in advance.
>
> Regards,
> George
>
> --
> 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
</Original message>
<Reply>
You can (possibly) just redirect before the rest of your script.
Ofcourse you can't do that when the rest of the script produces
output, but it seems to me like it doesn't.
Try the next code:
--- PHP code ---
<?php
header ("Location: http://somewhere.com");
error_log ("And still my script is running!", 0);
?>
--- End of PHP code ---
You'll see that the original script will write the line to the
logfile although the user is already redirected to the next page.
Btw... 30 seconds is a rather long time. No user will ever want to
wait that long. Just my opinion...
</Reply>
--
* R&zE:
-- »»»»»»»»»»»»»»»»»»»»»»»»
-- Renze Munnik
-- DataLink BV
--
-- E: renze@datalink.nl
-- W: +31 23 5326162
-- F: +31 23 5322144
-- M: +31 6 21811143
--
-- Stationsplein 82
-- 2011 LM HAARLEM
-- Netherlands
--
-- http://www.datalink.nl
-- ««««««««««««««««««««««««