Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Layouts in PHP and redirection

Layouts in PHP and redirection

Scheduled Pinned Locked Moved Web Development
phpdatabasehelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Quake2Player
    wrote on last edited by
    #1

    Hi, I have an index.php that takes a $_GET variable, "action", like this: index.php?action=someContent And based on the value of "action" I include some php in some div in the body. The problem is that if I have some logic in those included contents, and they need to redirect the user (using header("..")), they can't because of "Warning: Cannot modify header information - headers already sent by" So.. I either need 1. A way to redirect without header 2. or a way to create a layout more efficient than that

    P 1 Reply Last reply
    0
    • Q Quake2Player

      Hi, I have an index.php that takes a $_GET variable, "action", like this: index.php?action=someContent And based on the value of "action" I include some php in some div in the body. The problem is that if I have some logic in those included contents, and they need to redirect the user (using header("..")), they can't because of "Warning: Cannot modify header information - headers already sent by" So.. I either need 1. A way to redirect without header 2. or a way to create a layout more efficient than that

      P Offline
      P Offline
      Peter_in_2780
      wrote on last edited by
      #2

      You can only write headers from PHP before you output anything else. If you can rearrange your PHP code so that the first thing you actually write is the header, it'll all work. Gotcha to watch out for: any whitespace before the <?php tag counts as output!

      Software rusts. Simon Stephenson, ca 1994.

      Q 1 Reply Last reply
      0
      • P Peter_in_2780

        You can only write headers from PHP before you output anything else. If you can rearrange your PHP code so that the first thing you actually write is the header, it'll all work. Gotcha to watch out for: any whitespace before the <?php tag counts as output!

        Software rusts. Simon Stephenson, ca 1994.

        Q Offline
        Q Offline
        Quake2Player
        wrote on last edited by
        #3

        Thanks for replying Though, I know that, that's why i'm asking for a better way of doing layouts.. so that I dont have the content's logic after heads, body, etc tags Ps. ob_start() and ob_flush() worked for me.. but its not a very elegant solution

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups