I have a main webpage that logs in and redirects using header() without any problems.
I also have another webpage that would need to log in, so I made another login.php page for it.
Both webpages have the same structure, in fact I just copy-pasted the main webpage into the other webpage and changed var names, etc
If I log in in the main webpage everything is allright, no warnings. But if I log in in the other webpage I get the following warning:
Warning: Cannot modify header information - headers already sent by (output started at /home/aet/platform.corporativelines.com/themes/aet/main.php:12) in /home/aet/platform.corporativelines.com/pages/login.php on line 18
This is main.php:12
<title>AET | <?php print $title ?></title>
And this is login.php line 18
header("Location: /home");
The main webpage have the same in those lines, exactly the same but no warnings... Can someone tell me why?
Both webpages are in a subdomain, but main is just temporary, I'll move it when is finished. Maybe that have something to do... (If you want to visit, "pre" is the temporary subdomain)
The framework is the same for both webpages, the custom session start function have the domain set to ".domain.com" like says here.
PHP Code:
index.php (both websites):
ini_set('display_errors', '1');
//requires and initializations
$hasExpired = $web_user::sec_session_start();
$client = $web_user->login_check(); // FALSE OR CLIENT
$isLogged = false;
$includes1 = array(
'/pages' => $pages . 'pages.php'
);
if ($client != false) {
$isLogged = true;
$includes2 = array(
'/morepages' => $pages . 'morepages.php'
);
}
else {
$includes2 = array(
'/otherpages' => $pages . 'otherpages.php'
);
}
$includes = array_merge($includes1, $includes2);
$url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
//some more security checks for url
$title = $lang->getW($url);
include('themes/aet/main.php');
main.php (both websites):
<?php
defined('_AET') or die();
?>
<!DOCTYPE html>
//html structure
<title>AET | <?php print $title ?></title>
//body
//main
<?php
$include = '/404';
if (array_key_exists($url, $includes)) {
$include = $url;
}
include($includes[$include]);
?>
login.php (both websites):
// login post, checks and call to function
if ($login_array[0] == "OK") {
header("Location: /home");
}
// login form html
I can say they are the same pages in both webpages.
EDIT: Sorry I have not been clear. In both websites I have ini_set('display_errors', '1'); In the main website I'm not getting any error plus the header() redirection is working fine. In the other website I'm getting the error, if I disable them, the error won't show but neither the redirection will work.