headers

Hi
I have a login check at the beginning of each page …an example:
[php]<?php

@session_start();
// >> START OF “after session init” [SESS001] [POST] [START] [SRV] [74927473-E5E6-47E6-9F06-64B0176D9DCB] [Mtas Data]
// << END OF “after session init” [SESS001] [POST] [STOP] [SRV] [74927473-E5E6-47E6-9F06-64B0176D9DCB] [Mtas Data] END>>
$_SESSION[“SkipConnectMySQL”] = “”;
require(‘qs_connection.php’);
require(‘qs_functions.php’);
//Check security login
$pagesecure_level = 3;

if (strtoupper(qsrequest(“logout”))==“Y”) {
$_SESSION[“Mtas_UserLevel”] = 0;
$_SESSION[“Mtas_Logon”] = “FALSE”;
$_SESSION[“Mtas_UserLogon”] = “”;
$_SESSION[“Mtas_RedirectURL”] = qssession(“firstredirecturl”);
header (“Location: ./mtas_login.php”);

exit();

}

if (qssession(“Mtas_Logon”) != “TRUE”) {
$_SESSION[“Mtas_RedirectURL”] = “./” . rawurlencode(“brochure”).".php?" . qsservervars(“QUERY_STRING”);
header (“Location: ./mtas_login.php”);

exit();

}

if (qssession(“Mtas_UserLevel”) == “”) {
$_SESSION[“Mtas_UserLevel”] = 0;
}
if (qssession(“Mtas_UserLevel”) < $pagesecure_level) {
$_SESSION[“Mtas_Logon”] = “FALSE”;
$_SESSION[“Mtas_RedirectURL”] = “./” . rawurlencode(“brochure”).".php?" . qsservervars(“QUERY_STRING”);
include_once(‘mtas_login.php’);

exit();

}
?>
[/php]

However I am getting this error:
Warning: Cannot modify header information - headers already sent by (output started at /home/mtas/public_html/mtas/index.php:1) in /home/mtas/public_html/mtas/index.php on line 26

Line 26 = ($_SESSION[“Mtas_RedirectURL”] = “./” . rawurlencode(“brochure”).".php?" . qsservervars(“QUERY_STRING”):wink:

Can anybody see my mistake

The error basically says that headers are being sent AFTER the browser is recieving stuff from the server. All headers have to be sent before.

Ok it works on another site in the same directory, but I understand why now.
I just need a simple script to check their security level, (3) & if not logged on to redirect to login.

Sponsor our Newsletter | Privacy Policy | Terms of Service