Results 1 to 3 of 3

Thread: seeks redirect alternative to header()

  1. #1
    Join Date
    Jan 2006
    Location
    up here in my tree
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question seeks redirect alternative to header()

    i'm getting the classic Warning: Cannot modify header information - headers already sent by ...
    i'm wondering if there's something i can use-- javascript-wise, which will allow me to get around this w/out causing any harm to the integrity of the app?

    i forget how to fix the headers problem, and furthermore-- it's an include() issue which i'm thinking will be more tricky to fix the header issue than usual. (used to get the header thing all the time, but i figured out how to fix it a while ago-- hence why i can't recall momentarily)

    any ideas?

    thanks!

    it's basically an if / elseif thing where i need, upon elseif to send the user to a particular page. thanks!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You can do this client-side using:
    Code:
    <meta http-equiv="0;url=page-to-go-to.html" />
    in the head of your page. However, doing it server-side is better. To understand the nature of your problem, you must know (basically) how HTTP works. First, the page headers are sent; then comes the main body of the file. To seperate the two, two CRLFs are used. Obviously, once the headers have been sent, you can't pull them back and edit them. The way to avoid this error, then, is to perform all header() calls before you output any HTML.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    However, doing it [redirection] server-side is better.
    Yes, much.

    The way to avoid this error, then, is to perform all header() calls before you output any HTML.
    Which isn't as awkward as it may seem if output buffering is employed.

    Mike

Bookmarks

Posting Permissions

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