register & login

14/09/2003 - 19:08 por news.microsoft.com | Informe spam
hi
i would like to find information to help me a page.
first considerations:
i'm using iis 5
i want to create a webpage to control login using asp
for acessing you must register before, using a form that i created and
stores the information on a access database.
i want to validate the acess and then forward to the starting page
the fields for validate are login and password

i'm sure i saw that information here before but i can't find it.

I understand spanish also, so language wouldn't be the problem.
Any help or information will be appreciated
Thank you
 

Leer las respuestas

#1 Pablo Ramírez A.
15/09/2003 - 15:27 | Informe spam
Hi,
You have to create a Session.
Te envio un ejemplo.
En cada pagina que quieras autenticar el usuario o
restringir el acceso tienes que colocar al principio el
siguiente código.

"<%Response.Buffer=True%>
<%
if Session("autorizacion")<>1 then
Response.redirect "default.asp"
end if
%>"

Espero te ayude.

Pablo

"<%if request.form("usuario")="" then%>"


<CENTER>
<form method="POST" action="default.asp">
<p>&nbsp;</p>
<IMG src="images/Autentica.gif" width="285" height="46"
border="0" alt="Autentificación de Usuarios">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center"><%=request.querystring("msg")%></p>
<div align="center">
<center>
<table border="0" width="15%" bgcolor="#F2F2F2">

<tr>
<td width="100%" colspan="2" bgcolor="#0000FF">
<p align="center"><font color="#FFFFFF"><B>Ingrese
Usuario y Password</B></font>
</td>
</tr>
<tr>
<td width="50%">Usuario:</td>
<td width="50%"><input type="text" name="usuario"
size="8" maxLength="8"></td>
</tr>
<tr>
<td width="50%">Password:</td>
<td width="50%"><input type="password"
name="password" size="7" maxLength="7"></td>
</tr>
<tr>
<td width="100%" colspan="2">
<p align="center"><input type="submit"
value="Enviar" name="B1">
</td>
</tr>

</table>
</center>
</div>
</form>
</CENTER>
<%else
'eliminamos las posibles comillas de la entrada
'para evitar la introducción de sentencias SQL
usuario=replace(request.form("usuario"),"'","")
password=replace(request.form("password"),"'","")

Dim Sqltxt, Rs, Conn, ConnStr
ConnStr = "DSN=XXXX;XXXX;PWD=XXXX"

Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.Open ConnStr

sqltxt="Select * from usuarios where Login='"&usuario&"'
and pass= '"&password&"'"
response.write sqltxt

rs.Open sqltxt, conn
if not rs.eof then
' nos ha devuelto un registro, ahora miraremos si es valido
' con ello evitamos el ataque típico SQL
if rs("Login")=usuario and rs("pass")=password then
' si el usuario esta en la base de datos y la password
coincide
session("autorizacion")=1
Session("VLogin")=usuario
response.redirect "Menu.asp"
end if
else
session("autorizacion")=-1

end if
rs.close
set rs=nothing
conn.close
set conn=nothing
if session("autorizacion")=-1 or session("autorizacion")
="" then
' no hemos encontrado el registro
' eso indica que el usuario y/o la password son erroneos
response.redirect "default.asp?msg=Usuario%20o%20password%
20incorrecta"
end if

end if%>






hi
i would like to find information to help me a page.
first considerations:
i'm using iis 5
i want to create a webpage to control login using asp
for acessing you must register before, using a form that


i created and
stores the information on a access database.
i want to validate the acess and then forward to the


starting page
the fields for validate are login and password

i'm sure i saw that information here before but i can't


find it.

I understand spanish also, so language wouldn't be the


problem.
Any help or information will be appreciated
Thank you


.

Preguntas similares