Header Warnings are gone, but page still does not work correctly
I used the output buffering suggestion, and that seemed to work. But now, instead of getting the login box on the page, i get 2 login boxes, and the page where i should go after i login. Please look at this script and see if you can help me find something wrong...
PHP Code:
<?
// start buffering the output
ob_start();
include_once "/home/blah/public_html/userclient/conf.php";
if($logout){
if($admin_auth_type=="se"){
//session type authentication..
if($login){
//log the user in...
session_register("username", "password");
$username=$username;
$password=$password;
echo '<head><title>Sorry no access!</title></head><center><font face="verdana,arial" size=2><B>You have been loged in, now forwarding to admin center...</center></B></font>';
echo '<script language=javascript> window.location="index.php" </script>';
}else{
//retrieve the username and password.
$username=$HTTP_SESSION_VARS[username];
$password=$HTTP_SESSION_VARS[password];
}
//check the username and password!..
if(mysql_num_rows($data=mysql_query("SELECT * FROM admins WHERE username='$username' && password='$password'"))!=1 ||$logout){
setcookie("username", "", time()+1);
setcookie("password", "", time()+1);
$login_now=1; //so no error is displayed!
}else{
$admin_id=mysql_fetch_array($data);
$admin_id=$admin_id[id];
}
}else{
//cookie type authentication
if($login){
//log the user in...
setcookie("username", $username, time()+2000);
setcookie("password", $password, time()+2000);
echo '<head><title>Sorry no access!</title></head><center><font face="verdana,arial" size=2><B>You have been loged in, now forwarding to admin center...</center></B></font>';
echo '<script language=javascript> window.location="index.php" </script>';
}else{
//retrieve the username and password.
$username=$HTTP_COOKIE_VARS[username];
$password=$HTTP_COOKIE_VARS[password];
}
//check the username and password!..
if(mysql_num_rows($data=mysql_query("SELECT * FROM admins WHERE username='$username' && password='$password'"))!=1 ||$logout){
setcookie("username", "", time()+1);
setcookie("password", "", time()+1);
$login_now=1; //so no error is displayed!
} else{
$admin_id=mysql_fetch_array($data);
$admin_id=$admin_id[id];
}
}
//now check the current admin is allowed on this page!
//check if this admin is allowed in this section.
$res=mysql_fetch_array(mysql_query("SELECT * FROM admins WHERE id='$admin_id'"));
$rights=explode(",", $res[privelages]);
if($section=="general" || !$section){$verified=1;}
foreach($rights as $right){
if($right==$section){$verified=1;break;}
}
//check if this admin is allowed to work on this project!
if($project && $verified){
$xes=mysql_fetch_array(mysql_query("SELECT * FROM projects WHERE id='$project' && status!='1'"));
if($res[id]==$xes[project_manager]){$project_verified=1;}
$adm=explode(",", $xes[admins]);
foreach($adm as $ad){
if($ad==$admin_id){$project_verified=1;break;}
}
}else{
$project_verified=1;
}
if($login_now){
//display the html login form!
echo' <html>
<head>
<title>Please Login!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
if($project_verified && $verified){
}else{
if(!$login_now){ echo '<head><title>Sorry no access!</title></head><center><font face="verdana,arial" size=2 color=red><B>SORRY YOU DO NOT HAVE THE PRIVELAGES NECCESARY TO ACCESS THIS PAGE!</center></B></font>'; }
exit;
}
?>
If anyone can see a problem with the script, helping me out would be greatly appreciated...