Php output buffer and the header function [duplicate]
This question already has an answer here:
Headers already sent by PHP 10 answers
I have 2 php files included in my php file and a function to check if the
user not logged then it redirects him to the signup page.
<?php require_once("includes/session.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php confirm_logged_in(); ?>
The problem am getting is from the functions.php file that contains the
redirect function that i used inside confirm_logged_in() function.
function redirect_to( $location = NULL ) {
if ($location != NULL) {
header("Location: {$location}");
exit;
}
}
Confirm Logged In function code sits inside the session.php file that
already included in this page:
function confirm_logged_in() {
if (!logged_in()) {
redirect_to("signin.php");
}
}
I don't want to use Output buffering method to fix this. I believe there
is something needs to be fixed.
No comments:
Post a Comment