Tema: ¿Que falla?
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/11/2003, 14:51
aruizroldan
 
Fecha de Ingreso: octubre-2003
Mensajes: 280
Antigüedad: 20 años, 7 meses
Puntos: 1
¿Que falla?

Hola. Tengo una base de datos en access, en la que las columnas son usuario, contrasena, nombre, apellidos, dni, mail, direccion.

quiero que metiendo el usuario y contraseña me salga la informacion sobre el resto de los campos.

Os envio el codigo de los ficheros, para ver si podeis ayudarme.

Buscador.asp
----------------

<html>

<head>
<title>Alaporra.com</title>
</head>

<body>

<div align="center">
<center>
<form method="GET" action="resultados.asp">
<table border="1" cellpadding="2" cellspacing="0" style="border-collapse: collapse" bordercolor="#C0C0C0" width="58%" id="AutoNumber1">
<tr>
<td width="104%" align="right" style="border-right-style: none; border-right-width: medium; border-bottom-style: none; border-bottom-width: medium" bgcolor="#000000" colspan="2">
<p align="center"><b><font face="Arial" size="2" color="#FFFFFF">Búsqueda de los datos del usuario</font></b></td>
</tr>
<tr>
<td width="39%" align="right" style="border-right-style: none; border-right-width: medium; border-bottom-style: none; border-bottom-width: medium" bgcolor="#EBEBEB">
<b><font face="Arial" size="2">Usuario</font></b></td>
<td width="65%" style="border-left-style: none; border-left-width: medium; border-bottom-style: none; border-bottom-width: medium" bgcolor="#EBEBEB">
<font face="Arial"><input type="text" name="usuario" size="20"></font></td>
</tr>
<tr>
<td width="39%" align="right" style="border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium" bgcolor="#EBEBEB">
<b><font face="Arial" size="2">Contraseña</font></b></td>
<td width="65%" style="border-left-style: none; border-left-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium" bgcolor="#EBEBEB">
<font face="Arial"><input type="text" name="contrasena" size="20"></font></td>
</tr>

<tr>
<td width="39%" align="right" style="border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium" bgcolor="#EBEBEB"> </td>
<td width="65%" style="border-left-style: none; border-left-width: medium; border-top-style: none; border-top-width: medium" bgcolor="#EBEBEB">
<font face="Arial"><input type="submit" value="Buscar"></font></td>
</tr>
</form>
</center>
</div>

</body>

</html>


Resultados.asp
-------------------

<%
Dim mostrar 'cantidad de registros a mostrar por página
Dim cant_paginas 'cantidad de páginas que recibimos
Dim pagina_actual 'La página que mostramos
Dim registro_mostrado 'Contador utilizado para mostrar las páginas
Dim I 'Variable Loop
usuario = request.querystring("usuario")
contrasena = request.querystring("contrasena")
nombre = request.querystring("nombre")
orden = request.querystring("orden")
alf = request.querystring("alf")
cantidad = request.querystring("cantidad")
if cantidad="10" then
mostrar = 10
elseif cantidad="20" then
mostrar = 20
elseif cantidad="30" then
mostrar = 30
end if
if orden = "" then
response.redirect "buscador.asp"
end if

IF para saber que página mostrar
If Request.QueryString("page") = "" Then
pagina_actual = 1
Else
pagina_actual = CInt(Request.QueryString("page"))
End If

strsql = "SELECT * FROM tabla_datos where UCase(usuario) like '%" & UCase(Request("usuario")) & "%' AND UCase(contrasena) like '%" & UCase(Request("contrasena"))

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="&Server.MapPath("./bd/alaporra_com.mdb")

' creo el RecordSet y defino la cantidad de registros a mostrar
Set RS = Server.CreateObject("ADODB.Recordset")
RS.PageSize = mostrar
RS.CacheSize = mostrar

' Abro la tabla...
RS.Open strSQL, oConn,3,1
'cuento las páginas que se formaron con la variable mostrar
cant_paginas = RS.PageCount

' Si el pedido de página cae afuera del rango,
' lo modifico para que caiga adentro
If pagina_actual > cant_paginas Then pagina_actual = cant_paginas
If pagina_actual < 1 Then pagina_actual = 1
%>
<body style="background-color: #FFFFF4">
<%
' Si la cantidad de páginas da 0 es que no hay registros... por eso este IF
If cant_paginas = 0 Then%>

<p><font face="Arial">Se encontraron <font color="#FF0000"> <b>0</b> resultados</font></font></p>

<ul>
<li><font face="Arial"><a href="buscador.asp">Buscar nuevamente</a></font></li>
<li><font face="Arial">
<a href="resultados.asp?orden=Contraseña&usuario=<%=u suario">Repetir la búsqueda sin restricciones</a></font></li>
</ul>
<%
'sino, si es que encuentra registros
Else
' Nos movemos a la página elegida
RS.AbsolutePage = pagina_actual
' muestra el dato de la página en la que estamos...
%>
<div align="center">
<center>
<table border="1" cellspacing="1" style="border-width:0; border-collapse: collapse" bordercolor="#111111" width="80%" id="AutoNumber1">
<tr>
<td width="29%" bgcolor="#CCCCFF" style="border-left:medium none #111111; background-color: #DDDDFF; border-right-style:none; border-right-width:medium; border-top-style:none; border-top-width:medium; border-bottom-style:none; border-bottom-width:medium" align="center">
<p style="text-align: left"><b><font color="#003366" face="Arial" size="2">
Contraseña </font></b></td>
<td width="36%" bgcolor="#CCCCFF" style="border-style: none; border-width: medium; background-color: #DDDDFF; text-align:center">
<font color="#003366" face="Arial" size="2"><b>Usuario</b></font></td>
<td width="13%" bgcolor="#CCCCFF" style="border-style: none; border-width: medium; background-color: #DDDDFF" align="center">
<p align="center"><font color="#003366" face="Arial" size="2"><b>Apellidos</b></font></td>
<td width="10%" bgcolor="#CCCCFF" style="border-style: none; border-width: medium; background-color: #DDDDFF" align="center">
<p align="center"><font color="#003366" face="Arial" size="2"><b>Nombre</b></font></td>
<td width="18%" bgcolor="#CCCCFF" style="border-right:medium none #111111; background-color: #DDDDFF; border-left-style:none; border-left-width:medium; border-top-style:none; border-top-width:medium; border-bottom-style:none; border-bottom-width:medium" align="center">
<p align="center" style="text-align: center">
<font color="#003366" face="Arial" size="2"><b>DNI</b></font></td>
</tr>
<%

' Hacemos el bucle mostrando los datos del registro
registro_mostrado = 0
Do While registro_mostrado < mostrar And Not RS.EOF
if colorfila = 0 then
color= "#FFFFFF"
colorfila=1
else
color="#F3F3F3"
colorfila=0
end if
%>

<tr>
<td width="29%" style="border-style:none; border-width:medium; background-color: <%= color %>; "><font face="Arial" size="2"><b><%=RS("contrasena")%></b> </td>
<td width="36%" style="border-style:none; border-width:medium; background-color: <%= color %>; text-align:left; "><font face="Arial" size="2"><%=RS("usuario")%></a></font> </td>
<td width="13%" align="center" style="border-style:none; border-width:medium; background-color: <%= color %>; text-align:center; "><font face="Arial" size="2"><%=RS("apellidos")%> </td>
<td width="10%" align="center" style="border-style:none; border-width:medium; background-color: <%= color %>; text-align:center; "><font face="Arial" size="2"><%=RS("nombre")%> </td>
<td width="18%" align="center" style="border-style:none; border-width:medium; background-color: <%= color %>; text-align:center; ">
<p><font face="Arial" size="2" color="#FF0000">$<%=RS("dni")%> </td>
</tr>
<%
' Sumamos 1 a los mostrados
registro_mostrado = registro_mostrado + 1
' Nos movemos al próximo registro...
RS.MoveNext
Loop

End If
%>
</table>

</center>
</div>

<%
' Cerramos y limpiamos...
RS.Close
Set RS = Nothing
oConn.Close
Set oConn = Nothing
%>
<div align="center"><br>
<font size="2" face="Arial">
<%
' Ahora mostramos los enlaces a las otras páginas con el resto de los registros...
If pagina_actual > 1 Then
%> </font><font size="2"> <a href="resultados.asp?eje=30&page=<%= pagina_actual - 1 %>&usuario=<%=usuario%>&contrasena=<%=contrasena%> ">
<font face="Arial">[</font><b><font face="Arial"><<</font></b><font face="Arial"> anterior ]</font></a><font face="Arial"> <%
End If

' mostramos la paginacion por numeros de página
For I = 1 To cant_paginas
If I = pagina_actual Then
%> <font color="#FF3300">
<b><%= I %></b></font>
<%
Else
%>
<a href="resultados.asp?eje=30&page=<%= I %>&usuario=<%=usuario%>&contrasena=<%=contrasena%> "><%= I %></a>
<%
End If
Next 'I

If pagina_actual < cant_paginas Then
%> </font> <a href="resultados.asp?eje=30&page=<%= pagina_actual + 1 %>&usuario=<%=usuario%>&contrasena=<%=contrasena%> ">
<font face="Arial">[ </font>
</font>

<font size="2" face="Arial"> siguiente
</font>

<font size="2">
<b><font face="Arial">>></font></b></font><font face="Arial" size="2">]</font></a><font size="2">
<br>
</font>

<%
End If
'Fin
%>
</div>

<br><center><font face="Arial" size="1"><a href="buscador.asp">Buscar de nuevo</font><font size="2"><a/>
</a></font>

</BODY>
</HTML>


Espero vuestra ayuda.