Pagina PHP con restriccion de usuario y pass. Crear archivo passwords.txt en la misma raiz del sitio, con la siguiente informacion. ejemplos: [FONT=Courier New, Courier, mono]Usuario|Contraseña[/FONT] [FONT=Courier New, Courier, mono]administrador|administrador mandr4k3|portalnet [/FONT] Script: [FONT=Courier New, Courier, mono]<?php // Mandr4k3 if (!isset($PHP_AUTH_USER)) { header('WWW-Authenticate: Basic realm="Acceso restringido"'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.'; exit; } $fich = file("passwords.txt"); $i=0; $validado=false; while ($fich[$i] && !$validado) { $campo = explode("|",$fich[$i]); if (($PHP_AUTH_USER==$campo[0]) && ($PHP_AUTH_PW==chop($campo[1]))) $validado=true; $i++; } [/FONT] if (!$validado) { header('WWW-Authenticate: Basic realm="Acceso restringido"'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.'; exit; } ?> [FONT=Courier New, Courier, mono]<!-- Mandr4k3 --> <html> <head> <title>pagina prueba</title> </head> <body> [/FONT][FONT=Courier New, Courier, mono]Ha conseguido el acceso a la <B>zona restringida</B> con el usuario [/FONT][FONT=Courier New, Courier, mono]<?php echo $PHP_AUTH_USER?>[/FONT][FONT=Courier New, Courier, mono]. </body> </html>[/FONT]
Amigo, y tienes lo mismo pero con conexion a una base de datos donde la base(usuarios) se compone de usuario y password .Hecho en PHP y MYSQL Ayuda plis mi mail [email protected]