Results 1 to 5 of 5

Thread: [RESOLVED] redirect in PHP?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Resolved [RESOLVED] redirect in PHP?

    Hello,

    Right now, I can only redirect to another page in PHP using the header ('location: ') command, but it only works if no content was flushed to the browser.

    Is there any way to redirect in PHP even with some content already flushed to the browser? Like the Server.Transfer() of ASP.NET.

    Thanks,
    HoraShadow
    I do like the reward system. If you find that my post was useful, rate it.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: redirect in PHP?

    Not really - HTTP does not support that.
    The best you can achieve is to add in a meta refresh element (but that doesn't work once you're past the head section) or, heaven forbid, a JavaScript redirect. Neither are acceptable solutions.

    You should do all processing before outputting anything. That way, you know in advance whether or not you need to redirect, and hence avoid running into this issue at all.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: redirect in PHP?

    Thanks for your reply Penagate.

    How do I accomplish that?

    Thanks,
    HoraShadow
    I do like the reward system. If you find that my post was useful, rate it.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: redirect in PHP?

    Make sure all of your application logic is concluded before beginning output on any page. This usually involves storing various things to variables and then echoing those further on in the HTML (once you've determined whether or not you want to display the page or redirect).

    Is there a more specific problem you have?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: redirect in PHP?

    Hi Penagate,

    I thought it was an option of the php.ini configuration file.

    Thanks for the reply.

    HoraShadow
    I do like the reward system. If you find that my post was useful, rate it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width