Código PHP:
function auth($nombre,$password) {
$sql = "select * from panel"; //Obtendo los datos de mySQL
$consulta = mysql_query($sql);
$fila = mysql_fetch_array($consulta);
$mysql_nombre = $fila['nombre'];
$mysql_password = $fila['password'];
if($nombre != $mysql_nombre and $password != $mysql_password) {
return false;
} else {
return true;
}//else
} //function
//Si mi funcion "auth()" es falsa entonces mando las cabeceras HTTP de autentificación.
if(!auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
header('WWW-Authenticate: Basic realm="Panel"');
header('HTTP/1.0 401 Unauthorized');
echo "<b>No</b> tienes permiso para acceder";
exit();
} //if
Código PHP:
function auth($nombre,$password) {
$mysql_nombre = "usuario";
$mysql_password = "pass";
if($nombre != $mysql_nombre and $password != $mysql_password) {
return false;
} else {
return true;
}//else
} //function
if(!auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
header('WWW-Authenticate: Basic realm="Panel"');
header('HTTP/1.0 401 Unauthorized');
echo "<b>NO</b> tienes permiso para acceder";
exit();
} //if
Localmente tengo lo siguiente:
Apache/2.0.59 (Win32)
PHP version:5.1.6
MySQL version:5.0.24a-community-nt
Mi servidor tiene lo siguiente:
Apache 1.3.37 (Unix)
MySQL 4.1.21-standard
PHP 4.4.3
Cualquier idea será muy bien recibida. Gracias!