salamander
12-05-2002, 11:13 AM
Hi folks,
I'm trying to get HTTP Authentication working with PHP on an Ensim box - keep getting document contains no data errors.
The code i'm trying is this:
<?php
function authenticate ($realm="Secure Area" ,$errmsg="Please enter a username and password") {
header('WWW-Authenticate: Basic realm="$realm"');
header('HTTP/1.0 401 Unauthorized');
die($errmsg);
}
if (empty($PHP_AUTH_USER)) {
authenticate($realm,$errmsg,"header");
} else {
$query = "select * from users
where password = password(lower('$PHP_AUTH_PW'))
and username = lower('$PHP_AUTH_USER')
";
$result = safe_query($query);
if ($result) { $valid_user = mysql_fetch_array($result); }
if (!$result || empty($valid_user)) {
authenticate($realm,$errmsg,"query");
} else {
$isAdmin = $valid_user['isAdmin'];
}
}
?>
any ideas?
I'm trying to get HTTP Authentication working with PHP on an Ensim box - keep getting document contains no data errors.
The code i'm trying is this:
<?php
function authenticate ($realm="Secure Area" ,$errmsg="Please enter a username and password") {
header('WWW-Authenticate: Basic realm="$realm"');
header('HTTP/1.0 401 Unauthorized');
die($errmsg);
}
if (empty($PHP_AUTH_USER)) {
authenticate($realm,$errmsg,"header");
} else {
$query = "select * from users
where password = password(lower('$PHP_AUTH_PW'))
and username = lower('$PHP_AUTH_USER')
";
$result = safe_query($query);
if ($result) { $valid_user = mysql_fetch_array($result); }
if (!$result || empty($valid_user)) {
authenticate($realm,$errmsg,"query");
} else {
$isAdmin = $valid_user['isAdmin'];
}
}
?>
any ideas?
