This topic is locked
[SOLVED]

 Login then redirect

7/19/2010 09:23:37
PHPRunner General questions
K
kkiboo author

Hello,
I am trying to create a switch to redirect after logging in based on a value specified within the login table. Where can I put this code so that during/after logging in, it redirects to the page I specified and NOT the table view page? I understand that you can create an after login, redirect event but this will not satisfy because I need it to be based on a specific value. Here is the code:
switch($row['level']){
case0:

header("Location: user0.php"); //redirect to User 0's Homepage

break;
default:

header ("Location: main.php"); // redirect to main page if no permission is set

break;
}

A
ann 7/19/2010

Hi,
unfortunately it's impossible to add another fields to the Login page.

If the value depends on the logging in user (e.g. filled in before) you can use After successful login event on the Events tab:

$sql="select level from TableName where Id=".$_SESSION["UserID"];

$rs = CustomQuery($sql);

if($data=db_fetch_array($rs)){

switch($data['level']){

//your code here...

}

}



where TableName is your actual table name.

K
kkiboo author 7/19/2010

Thanks for the reply! The code is exactly what I want, however, when I implement it, I get the error ORA-00904: invalid identifier. Its saying that I have misidenitified the column, but I checked the code over and over again, I haven't.

$sql="select userlevel from LOGIN where USERNAME=".$_SESSION["UserID"];

$rs = CustomQuery($sql);

if($data=db_fetch_array($rs)){
switch($data['userlevel']){
case 0:

header("Location: test2.php"); //redirect to User 0's Homepage

break;
default:

header ("Location: main.php"); // redirect to main page if no permission is set

break;
}

}



Here are the error details:

ociexecute() [function.ociexecute]: ORA-00904: "soandso": invalid identifier

select userlevel from LOGIN where USERNAME=soandso
Is there any possible way you can help me?

A
ann 7/20/2010

Hi,
try to modify the first line in the following way:

$sql="select userlevel from LOGIN where USERNAME='".$_SESSION["UserID"]."'";



If it doesn't help please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error. 'Demo Account' button can be found on the last screen in the program.

K
kkiboo author 7/20/2010

That worked beautifully, thank you so much for your help! I spent 4 hours yesterday trying to figure out what was wrong, I put all sorts of quotes around the session ID, thinking that would help. Who knew it was a . that I needed! Thanks again, you're an angel.