Re: redirect with header() after headers sent
| From: | Simon Edwards | Date: | Wed, 30 Aug 2000 04:23:16 +0000 |
| Subject: | Re: redirect with header() after headers sent | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14314@lists.php.net to get a copy of this message | ||
scottrus@ipass.net wrote:
> Using the current release of php4 I want to issue a page redirect after
> the headers have already been sent. Here's the situation.
> How can I handle this situation? I would really prefer not to display the
> sql errors on the page that I was building because it's hard to tell
> where in the page the sql error might interrupt the html.
> snip!
> Not very user friendly when an error occurs.
Sorry if I seem to be questioning the question, but why don't you work
on your database or SQL calls so that the SQL *doesn't* fail. I mean,
what ever way you do it and SQL isn't friendly no matter what way you
deliver the news to the user...
Anyway, back in the Real World. First you probably want to read the PHP
config docs. I'm should there are ways of controlling where error
messages go (You should be able to stop PHP from putting messages in
your page). You could also store up everything after the prepend stuff
into a string, then output the string once you have finished with SQL.
This way if it fails you can detect that and output an error message
instead of the page body (or use include() to directly include the
errormsg.html file). THis way would not require a redirect.
One final hack method would be to open javascript to immediately kick
the user onto the error message page...
--
Simon Edwards
Animated Design, Melbourne
http://www.animated.net.au/ Ph: (03) 98850990