Switch/case/header/HELP

Soooo I’m tearing my hair out.
I am just trying to make a switch that, after a successful login, it checks for the userlevel of the user, passes it to a switch and based on the case, redirects to their respective page. Backend is Oracle 11g.

[php]<?php

// After successful login
function AfterSuccessfulLogin($username,$password,&$data)
{

$sql=“select userlevel from LOGIN where USERNAME=’”.$_SESSION[“UserID”]."’";
$rs = CustomQuery($sql);
if($data=db_fetch_array($rs)){
switch($data[“userlevel”]){
case “admin”:
header(“Location: AUDIT_TABLE_list.php”);
break;
case “redauditor”:
header(“Location: test2.php”);
break;
default:
header(“Location: main.php”); // redirect to main page if no permission is set
break;

}
}
;
} // function AfterSuccessfulLogin

?>[/php]

For the funky variables, forgive me, I’m modding PHPRunner stuff.
So, this logs the user in but it ONLY redirects to the first case specified. (In the code above: AUDIT_TABLE_list.php). If I change the cases to numbers (and equivalently change the datatype on the column to number as well) I get the same problem. If I quote the numbers, it displays the default page. Here are the things I know:
When I sqlplus at the command line, here is what this query returns:
SQL>select userlevel from login;

USERLEVEL
admin
redauditor

Therefore, I know that I did not mispell anything. Is it not fetching the array properly? What’s going wrong? How can I get it to recognize the other cases? Should I just start from scratch and make the switch without using the PHPRunner variables - if so, what does this look like for Oracle?

m._.m Any help is appreciated, thank you.

My initial thought looking at your function is this:

[php]function AfterSuccessfulLogin($username,$password,&$data)[/php]

should that not be:

[php]function AfterSuccessfulLogin($username,$password,$data)[/php]

Also the function relies on sessions to be on.
Are you including this file to another file that already has session_start(); at the top of the file?

Sponsor our Newsletter | Privacy Policy | Terms of Service