Using PHP, I have implemented Basic Authentication as follows:
if ((isset($_SERVER['PHP_AUTH_USER']) && $_SERVER['PHP_AUTH_USER']=='') || (isset($_SERVER['PHP_AUTH_PW']) && $_SERVER['PHP_AUTH_PW']=='')) {
header('WWW-Authenticate: Basic realm="Authentification"');
$UsrId = $objLDAP->authenticateUser();
die();
} elseif (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
$UsrId = $objLDAP->authenticateUser($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
}else{
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo '<script>window.location.reload();</script>';
//$UsrId = $objLDAP->authenticateUser();
//$smarty->display($templates['budWithoutAnyAccess']);
die();
}
if ($pUser){
//coding
}else{
header('HTTP/1.1 401 Authorization Required');
header('WWW-Authenticate: Basic realm="Access denied"');
$UsrId = $objLDAP->authenticateUser();
}
It opens up the login popup.
If user provides the wrong credentials, I can show error message on page but on page re-fresh it should open the Authentication login pop-up as well.
On cancel also, I want to show message and on refresh, it should open the Authentication login pop-up.
How can I do that?
Thank you, Trupti