Layouts in PHP and redirection
-
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
-
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
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.
-
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.
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