Forum Moderators: coopster
I am using header WWW-Authenticate for user credentials, and need to redirect to another page on unsucceessful login. The authentication is woking fine if i skip the header ("Location") part. As soon as the header ("Location") line is uncommented, NO RROMPT FOR USER CREDENTIALS, and it is redirected to the url specified in header(location).
Any help would be highly appreciated.
Please see the code below.
//In my page
if (!login()){
Header("Location: some_absolute_URL");
} else {
// REST OF THE CODE
}
//From library (using include)
function login(){
if (!isset($_SERVER['PHP_AUTH_USER'])){
Header("WWW-Authenticate: Basic realm=\"REALM\"");
Header("HTTP/1.0 401 Unauthorized");
return(FALSE);
} else {
//Database Connection and result on query
if($fetchedRow){
if (($_SERVER['PHP_AUTH_USER']==*db.USERNAME*) && ($_SERVER['PHP_AUTH_PW']==*db.PASSWORD*)){
return(TRUE);
} else {
return(FALSE);
}
}
else{
return(FALSE);
}
}
}