> -----Original Message-----
> From: Sándor Tamás (HostWare Kft.) [mailto:[EMAIL PROTECTED]
> Sent: 05 December 2008 14:58
> To: [email protected]
> Subject: Re: [PHP] Help with IF ELSE
>
> In fact, if I have to redirect, and I am not sure about headers are
> sent or
> not, I usually do:
>
> print('<SCRIPT>window.location=somewhere.php</SCRIPT>');
>
> That way I can always do the redirection.
I always use this little function for redirects
function redirect($url) { // redirect the page
if (headers_sent()) { // perform JS redirect
echo '<script type="text/javascript" language="javascript">';
echo "\n<!-- \n\tdocument.location.href='" . $url . "'; \n//
-->\n</script>\n";
echo '<a href="' . $url . '">Continue to your page</a>';
} else { // normal redirect
header('location: ' . $url);
die();
}
}
This just outputs a JS call to a redirect if headers have already been sent and
provides a link if the user has disabled JS (some do)
Also it should be XHTML compliant
Dan
> SanTa
>
> ----- Original Message -----
> From: "Andrew Ballard" <[EMAIL PROTECTED]>
> To: "David Stoltz" <[EMAIL PROTECTED]>
> Cc: <[email protected]>
> Sent: Friday, December 05, 2008 3:52 PM
> Subject: Re: [PHP] Help with IF ELSE
>
>
> > On Fri, Dec 5, 2008 at 6:42 AM, David Stoltz <[EMAIL PROTECTED]> wrote:
> >> I turned on error reporting (ALL) as you suggested. Nothing is being
> >> sent to the browser....still doesn't work if the recordset isn't
> empty.
> >>
> >> I'm wondering, is there any other way to do a redirect in PHP?
> >>
> >> Thanks
> >>
> >
> > That is how you do redirects in PHP. I believe you've got several
> > solutions to your actual problem by now (I like tedd's with either
> md5
> > or sha1), but since you asked...
> >
> > There is a note in the documentation for header() that says HTTP/1.1
> > requires absolute URIs instead of relative ones as those in your
> > example.
> >
> > You can also pass the response code in the third parameter (in which
> > case you can use the 303 SEE OTHER code that was intended for the
> > typical redirect rather than the 302 FOUND that most sites use), but
> > it isn' t necessary since PHP automatically sets a 302 on a Location:
> > header when the parameter is empty.
> >
> > http://www.php.net/header
> >
> > Andrew
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php