Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
  2. http://www.w3.org/TR/html4/loose.dtd">
  3. <!-- Desarrollo Web en Entorno Servidor -->
  4. <!-- Tema 4 : Desarrollo de aplicaciones web con PHP -->
  5. <!-- Ejemplo: Función header para autentificación HTTP -->
  6. <?php
  7. if ($_SERVER['PHP_AUTH_USER']!='dwes' || $_SERVER['PHP_AUTH_PW']!='abc123.') {
  8. header('WWW-Authenticate: Basic Realm="Contenido restringido"');
  9. header('HTTP/1.0 401 Unauthorized');
  10. echo "Usuario no reconocido!";
  11. exit;
  12. }
  13. ?>
  14. <html>
  15. <head>
  16. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  17. <title>Ejercicio: Función header para autentificación HTTP</title>
  18. <link href="dwes.css" rel="stylesheet" type="text/css">
  19. </head>
  20. <body>
  21. <?php
  22. echo "Nombre de usuario: ".$_SERVER['PHP_AUTH_USER']."<br />";
  23. echo "Contraseña: ".$_SERVER['PHP_AUTH_PW']."<br />";
  24. ?>
  25. </body>
  26. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement