Why is it that the scrip below works on three different linux remote servers, but not my local 2007 macbook apache 2.2 (PHP 5.2) server? (& by 'the script not working' I mean I get header warnings, "Cannot modify header information" from the line marked below.
On my remote servers, once the page loads, it goes directly to /admin.php?do=00, locally it just stays at /admin.php)
I'm getting so frusterated not being able to use this script... I'm thinking of paying someone to configure my macbook for me, but don't know where to find someone too in my small town, so I'm hoping someone here can help,
please help, any advice is greatly appreciated,
<?php
new admin;
global $DATA, $_SESSION;
class admin {
function admin() {
global $DATA, $_SESSION;
session_start();
//Connect to database info here
if($_SESSION['loggedin'] != '1' AND $_GET['do'] != '00' AND $_GET['do'] != '01') {
header("Location:admin.php?do=00"); //<<"Cannot modify header information - headers already sent by" .... (this line)
}
if($_SESSION['loggedin'] == '1' AND $_GET['do'] == '') {
header("Location:admin.php?do=02");
}
if($_GET['do'] != '01' AND $_GET['do'] != '99') {
//html head info here
}
//html head info here
switch($_GET['do']){
case '00':
$this->login();
break;
case '01':
$this->dologin();
break;
case '02':
$this->main();
break;
case '99':
$this->logout();
break;
}
//html footer info here
}
function login(){
global $_SESSION, $DATA;
if($_SESSION['loggedin'] == '1') {
header("Location:admin.php?do=02");
}
//login form here
}
function dologin(){
global $_SESSION, $DATA;
$error = '0';
if($_POST['username'] == '' OR $_POST['password'] == '') {
$error = '1';
}
//dehash password here
//setup variables here
$user = mysql_fetch_array($check);
if($user['password'] != $pass) {
$error = '1';
}
if($error == '0') {
$_SESSION['loggedin'] = '1';
$_SESSION['username'] = $_POST['username'];
header("Location:admin.php?do=02");
} else {
$this->login();
}
}
function main($msg="") {
global $_SESSION, $DATA;
//Check if logged in
if($_SESSION['loggedin'] != '1') {
$_SESSION['loggedin'] = '0';
$this->login();
} else {
//content seen when logged in here
}
}
function logout() {
global $_SESSION;
$_SESSION['loggedin'] = 0;
session_destroy();
header("Location:admin.php");
}
}
?>
Secondly, function cal_days_in_month() doesn't work locally, I've read its because something in php wasn't complied.... or something... can someone please shed light on that for me?
And lastly, I know its because of improper coding, but I get "Undefined index:" notices on every single page (using the same type of switch/case style of coding above) on my local server, but not my remote servers... what's up with that?
(I enabled apache and php with a tutorial on the web... I've done nothing and know nothing about why I'm having these problems)
Thanks in advanced,