Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/06/2007, 22:39
Avatar de charlyrosero
charlyrosero
 
Fecha de Ingreso: julio-2006
Mensajes: 161
Antigüedad: 17 años, 9 meses
Puntos: 5
Error en autenticacion http

Compadres, necesito de su ayuda

pues estoy haciendo solo un ejemplo de autentificacion por http con php, y para ello tomo el ejemplo de el manual de php.


Código PHP:
<?php
  
if (!isset($_SERVER['PHP_AUTH_USER'])) {
    
header('WWW-Authenticate: Basic realm="My Realm"');
    
header('HTTP/1.0 401 Unauthorized');
    echo 
'Text to send if user hits Cancel button';
    exit;
  } else {
    echo 
"<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
    echo 
"<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
  }
?>

y me genera un error :

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\Practicas\Ejemplos_Ejecucion.php:2) in C:\AppServ\www\Practicas\Ejemplos_Ejecucion.php on line 19

Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\Practicas\Ejemplos_Ejecucion.php:2) in C:\AppServ\www\Practicas\Ejemplos_Ejecucion.php on line 20


Alguien me puede decir donde esta el error ?

Código:
Uso las versiones PHP Version 5.2.1 y apache 2.2