php - Redirect (headers already sent); I know they're sent, but how do I re-organize this to make sense? -


i have index calls "header.php" prior loading actual pages so:

include 'includes/header.php';      if(isset($_get['page'])) {         include'includes/pages/page.php';     } 

and then, in page, want user able "add new page" (from index.php?add_page=1) , redirect them "edit page created" (from index.php?edit_page=).

if(isset($_post['add_page']) && $_post['add_page'] == 1) {     if(!$add_user['error']) {         //header("location: ".$page_url);         //echo "<script type='text/javascript'>document.location.href='{$page_url}';</script>";      } } 

the 'header("location:")' fails because headers have been sent (which makes sense me); but, how possible me redirect in post , skip header since it's redirecting edit page without having code directly in header.php?

quick answer: use javascript instead
header(location: yoururlhere);.

echo "<script type='text/javascript'>document.location.href='yoururlhere';</script>"; 

if want sure redirect happen client have javascript disable, use meta:

echo '<meta http-equiv="refresh" content="0;url=yoururlhere">'; 

"0" delay, in seconds, before redirect happen.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -