Red de conocimiento informático - Material del sitio web - ¿Cómo crear una página web donde solo puedas iniciar sesión ingresando tu nombre de usuario y contraseña?

¿Cómo crear una página web donde solo puedas iniciar sesión ingresando tu nombre de usuario y contraseña?

Soy un experto en páginas web dinámicas (dominio de los lenguajes de sitios web asp, ASP.NET y php). Voy a mostrarles el código de inicio de sesión de backend que escribí en php.

El primer paso: primero crea la página estática del cuadro de inicio de sesión.

Paso 2: Utilice php+sql para el inicio de sesión dinámico (nombre de archivo: login.php).

El código es el siguiente:

<? PHP session_start();? & gt

& lthtml & gt

& lthead & gt

& ltmeta http-equiv = " Tipo de contenido " Contenido = " texto/html; juego de caracteres =gb2312 " >>p>

& lttitle & gtCódigo de verificación tecnología de inicio de sesión

& lt/head & gt;

& ltstyle & gt

td{

Tamaño de fuente: 9pt

}

& lt/style & gt;

& ltLenguaje script = " javascript " & gt

Verificación de función (myform){

if(myform.txt_user.value==""){

Alerta("¡Ingrese el nombre de usuario! "); mi formulario . txt _ user . focus(); devuelve false

}

if(myform.txt_pwd.value==""){

Alerta("¡Ingrese su contraseña!");mi formulario . txt _ pwd focus(); return false

}

if(myform.txt_yan.value==". "){

Alerta("¡Ingrese el código de verificación!"); mi formulario . txt _ Yan . focus(); return false

}

if (myform.txt_yan.value!=myform.txt_hyan.value){

Alerta ("¡Lo siento, el código de verificación que ingresaste es incorrecto!"); mi formulario . devolver falso

}

}

& lt/script & gt

& ltbody & gt

& lttable ancho = " 693 " alto = " 346 " borde = " 0 " align = " centro " relleno de celda = " 0 " espacio entre celdas = " 0 " & gt;

& lttr & gt

& ltTD background = " imágenes/imagen _ 02 . png " & gt;

& ltform name="myform" método="post "? action = " checkuser.php " & gt

& lttable width = " 693 " border = " 0 " cellpacing = " 0 " cell padding = " 0 "

? & lttr & gt

& lttd height="42" colspan="5 " >& ampnbsp& lt/TD & gt;

? </tr>

? & lttr & gt

& ltTD width = " 154 " height = " 117 " rowspan = " 4 " >& ampnbsp& lt/TD & gt;

& ltTD height = " 13 " colspan = " 3 " align = " centro " v

align = " top " >& ampnbsp& lt/TD & gt;

& lttd width="160" rowspan="4 " >& ampnbsp& lt/TD & gt;

? </tr>

? & lttr & gt

& ltTD width = " 99 " height = " 30 " align = " right " valign = " middle " >Nombre de usuario:

& ltTD colspan = " 2 " align = " left " valign = " middle " >& ltinput type = " text " name = " txt_user " & gt;& lt/TD & gt;

? </tr>

? & lttr & gt

& ltTD height = " 30 " align = " right " valign = " middle " >Código secreto:

& ltTD height = " 30 " colspan = " 2 " align = " left " valign = " middle " >& ltinput type = " contraseña " nombre = " txt _ pwd " onCopy = " return false " onCut = " return false " on paste = " return false " maxlength = " 60 " >& lt/TD >

? </tr>

? & lttr & gt

& ltTD height = " 30 " align = " right " valign = " middle " >Código de verificación:

& ltTD width = " 218 " height = " 32 " align = " left " valign = " middle " >& ltinput type = " text " name = " txt _ Yan " & gt;

& lt? ¿Lenguaje de programación del lado del servidor (abreviatura de Preprocesador de hipertexto profesional)

? $num=intval(mt_rand(1000,9999));

? for($I = 0;$i & lt4;$i++){

Echo "<img src=images/checkcode/". substr(strval($num),$I,1).

¿".gif>"? //Gráficos de números aleatorios

? }

? >?

& ltinput type = " oculto " nombre = " txt _ hyan " id = " txt _ hyan " valor = " <?php echo $num?>& gt

& lt/TD & gt;

& ltTD width = " 62 " align = " left " valign = " middle " >& ltinput type = " enviar " nombre = " enviar " valor = " iniciar sesión " onClick = " devolver cheque(mi formulario);"& gt& lt/TD & gt;

? & lt/tr & gt;

& lttd height="62 " colspan="5 " >& ampnbsp& lt/TD & gt;

? & lt/tr & gt;

& lt/table & gt;

& lt/form & gt;

& lt/TD & gt;

& lt/tr & gt;

& lt/table & gt;

& lt/body & gt;

& lt/html & gt;

El efecto es el siguiente: