Ver Mensaje Individual
  #2 (permalink)  
Antiguo 01/01/2002, 13:53
ldangelo
 
Fecha de Ingreso: enero-2002
Ubicación: Dentro del corralón
Mensajes: 287
Antigüedad: 22 años, 3 meses
Puntos: 0
Re: Sistema de usuarios II

Hola:
Espero te sirva.

<?
if ($name && $pw) {
$db = getDBConnection();
$result = mysql_query ("SELECT usrid, usrpwd as passwd
FROM usuario
WHERE usrname = '$name'
AND usrpwd = '$pw'", $db);

if (mysql_num_rows($result) == 1) {
while ($r = mysql_fetch_array($result)) {
setcookie("usrid", $r[usrid], time()+3600);
}
header("Location: main.php");
exit;
} else {
echo "Error de Login, intente nuevamente.<br>
<a href='login.php'>Regresar</a>";
}
}

?>
<center>
<table>
<form method=post>
<tr>
<td align=right>
<b><? echo "Usuario" ?>:</b>
</td>
<td>
<input type=text name=name>
</td>
</tr>
<tr>
<td align=right>
<b><? echo "Contraseña" ?>:</b>
</td>
<td>
<input type=password name=pw>
</td>
</tr>
<tr>
<td colspan=2 align=center>
<input type=submit value=<? echo "Ingresar" ?>>
</td>
</tr>
</table>

</center>

</body>
</html>

Saludos.


Leonardo D'Angelo
Buenos Aires
Argentina