Foros del Web » Programando para Internet » ASP Clásico »

Comparar informacion

Estas en el tema de Comparar informacion en el foro de ASP Clásico en Foros del Web. Un saludo a todos, tengo un problema que no he podido resolver en una base de datos de Mysql estoy guardando la informacion del usuario, ...
  #1 (permalink)  
Antiguo 17/08/2005, 12:10
Avatar de Kenshin  
Fecha de Ingreso: agosto-2004
Ubicación: Mexico
Mensajes: 47
Antigüedad: 19 años, 9 meses
Puntos: 0
Pregunta Comparar informacion

Un saludo a todos, tengo un problema que no he podido resolver en una base de datos de Mysql estoy guardando la informacion del usuario, pero mi problema es que cuando el usuario entra por segunda vez a la pagina ya no quiero que intorduzca sus datos si no que muestre solo su informacion que se obtuvo y a mi me sale otra vez el formulario es pero que me puedan auxiliar a qui les proporciono mi codigo espero que me ayuden plis



<%
'Comienzo del programa de captura de datos
dim ip,idioma,x,y,xy,a,b,str_temp,a1,con,g,h
Dim cnn, sqlText, sql, Tip, rs, I,numR
Dim sNombre,sDepto,sArea

'Recogo el formulario de Request.Form("Nombre)
sNombre = Trim(Request.Form("Nombre"))
sDepto = Trim(Request.Form("Depto"))
sArea = Trim(Request.Form("Area"))
'Nombre=request.form("Nombre")
'Si esta variable está vacía
'es que no hemos enviado el formulario
'así que lo muestro
if Len(sNombre) = 0 then

Formulario
else
'Tengo ya un nombre para insertar
'Creo los objetos Connection y Recordset
h= Now()
ip = Request.ServerVariables("REMOTE_ADDR")
idioma = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")
x=request.servervariables("http_user_agent")
str_varserver=request.servervariables("http_user_a gent")
str_temp=mid(str_varserver,instr(str_varserver,"(" )+1)
str_temp=mid(str_temp,1,instr(str_temp,")")-1)
mat=split(str_temp,";")
explorador=mid(str_varserver,1,instr(str_varserver ,"(")-1)+mat(1)
y = explorador
x = trim(mat(2))
xy=len(request.servervariables("http_user_agent"))
if xy<=50 then
a= "No tiene instalado el Service Pack"
else
b = trim(mat(3))


'rs.close
set rs= Nothing
' conn.close
Set conn = Nothing
'Abro el Recordset con la sentencia SQL
'definiendo oConn como el objeto Connection
'y cursor 1 y lock(cerrojo) 2
'Identifica el tipo del Browsner que usa el cliente
'===========================================
'Guardo los cambios
'end if
'================================================= =======
'Imprimo una fila de la tabla
'para cada registro que encuentre
Response.Write( "<TR>" & vbCrlf ) 'ip,software,x,y,xy,a,b
Response.Write( "<p>&nbsp;</p><TD><B>Fecha y hora es : "&h&"</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Tu Ip es: " & ip & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Idioma del Windows es: " & idioma & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Version del Intert Explorer es:" & y & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Version del Sistema Operativo es:" & x & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>" & a & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>" & b & "</B></TD><p></p>" & vbCrlf )
Response.Write( "</TR>" & vbCrlf )
'Pasamos al siguiente registro
'Olvidarte esto significa que vas a imprimir
'siempre el mismo registro... Un bucle infinito!
'Cierro la tabla
end if
'//////////////////////////////////////////////////////////

' cnn.Open "DSN=mantto"
'sql ="select nombre from ips where ip = & ip "
'sql = "SELECT * FROM nombre WHERE ip='"&ip&"'"
'rs.open sql,conn,1,1


'================================================= =======
End if
Sub Formulario
'Imprimo por pantalla el formulario
Response.Write("<FORM ACTION=""pc.asp"" METHOD=""post"">" & vbCrlf)
Response.Write("<P>Introduce tu nombre:" & vbCrlf)
Response.Write("<INPUT TYPE=""text"" NAME=""Nombre"" SIZE=""50""><p>" & vbCrlf)
Response.Write("<P>Introduce el departamento:" & vbCrlf)
Response.Write("<INPUT TYPE=""text"" NAME=""Depto"" SIZE=""50""><p>" & vbCrlf)
Response.Write("<P>Introduce el area:" & vbCrlf)
Response.Write("<INPUT TYPE=""text"" NAME=""Area"" SIZE=""50""><p>" & vbCrlf)
Response.Write("<INPUT TYPE=""submit"" VALUE=""Enviar"">" & vbCrlf)
Response.Write("</FORM>")
End Sub'Formulario
%>

<%
dim cuenta,actualiza
dns="DSN=pc"
set conn = Server.CreateObject("ADODB.connection")
conn.open(dns)
set rs = server.CreateObject("ADODB.Recordset")
'if rs.eof = false then
sql = "SELECT * FROM nombre WHERE ip='"&ip&"'"
rs.open sql,conn,1,1
if rs.eof = true then
con="insert into nombre (ip,nombre,dept('"&ip&"',' ',' ',' ',1)"
' conn.execute(nombre,area,visito) values
else
' ejecuta la consulta
'cnn.Execute (sql)
set rs = conn.Execute(sql)
end if
if rs.eof = false then
cuenta=rs.Fields("visito")+ 1
actualiza= "Update nombre set visito = '"&cuenta&"' WHERE '"&ip&"'=ip"
set rs = conn.Execute(actualiza)
Response.Write("<B>HAZ ENTRADO A LA PAGINA DE MANTENIMIENTO DE EQUIPO: </B>" & cuenta & " <i>VECES</i>" )
else
cuenta = 1
Response.Write("<B>HAZ ENTRADO A LA PAGINA DE MANTENIMIENTO DE EQUIPO: </B>" & cuenta & " <i>VECES</i>" )
end if
'Response.Write(rs.Fields("visito"))
sSQL="Update nombre Set Idioma='" & Idioma & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)
sSQL="Update nombre Set Version_IE='" & y & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)
sSQL="Update nombre Set Version_Windows='" & x & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)
sSQL="Update nombre Set Service_Pack='" & b & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)
sSQL="Update nombre Set Sin_Service_Pack='" & a & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)
sSQL="Update nombre Set Fecha='" & h & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)
' else
sSQL="insert into nombre (ip,Usuario,depto,area,visito,Idioma,Version_IE,Ve rsion_Windows,Service_Pack,Sin_Service_Pack,Fecha) values ('"&ip&"','"&sNombre&"','"&sDepto&"','"&sArea&"',' "&cuenta&"','"&idioma&"','"&y&"','"&x&"','"&b&"',' "&a&"','"&h&"')"
set RS = conn.Execute(sSQL)
'end if
%>
  #2 (permalink)  
Antiguo 17/08/2005, 15:13
Avatar de meru-kun  
Fecha de Ingreso: noviembre-2002
Ubicación: Madrid
Mensajes: 854
Antigüedad: 21 años, 6 meses
Puntos: 0
Sinceramente, es muy tarde y hay mucho código de por medio. Pero te diría como haría yo el tema, y si me aseguras que lo esta´s haciendo así, entonces mirare más en profundidad todo:
a) Se registra el usuario. En ese instante creas una variable de sessión, algo como session("isLogged")=1
b) En la pagina donde muestras el formulario, haces algo así:
if session("isLogged") = "1" then
... (muestras sus datos)
else
... (formulario)
end if

Creo que esa es la idea. Saludos!
__________________
Tu portal de manga y anime.
  #3 (permalink)  
Antiguo 18/08/2005, 10:40
Avatar de Kenshin  
Fecha de Ingreso: agosto-2004
Ubicación: Mexico
Mensajes: 47
Antigüedad: 19 años, 9 meses
Puntos: 0
Realice la operacion session de la siguiente manera.

Para que pueda mostrar los datos del usuario lo que comparo es la ip almacenada.

session ("ip") = 1


Y cuando el usuario entra por segunda vez lo realice de esta manera
<%
if session ("ip") = 1 then
dim cuenta,actualiza
dns="DSN=pc"
set conn = Server.CreateObject("ADODB.connection")
conn.open(dns)
set rs = server.CreateObject("ADODB.Recordset")
'if rs.eof = false then
sql = "SELECT * FROM nombre WHERE ip='"&ip&"'"
rs.open sql,conn,1,1
if rs.eof = true then
con="insert into nombre (ip,nombre,dept('"&ip&"',' ',' ',' ',1)"
' conn.execute(nombre,area,visito) values
else
' ejecuta la consulta
'cnn.Execute (sql)
set rs = conn.Execute(sql)
end if
if rs.eof = false then
cuenta=rs.Fields("visito")+ 1
actualiza= "Update nombre set visito = '"&cuenta&"' WHERE '"&ip&"'=ip"
set rs = conn.Execute(actualiza)
Response.Write("<B>HAZ ENTRADO A LA PAGINA DE MANTENIMIENTO DE EQUIPO: </B>" & cuenta & " <i>VECES</i>" )
else
cuenta = 1
Response.Write("<B>HAZ ENTRADO A LA PAGINA DE MANTENIMIENTO DE EQUIPO: </B>" & cuenta & " <i>VECES</i>" )
end if
'Response.Write(rs.Fields("visito"))
sSQL="Update nombre Set Idioma='" & Idioma & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)
sSQL="Update nombre Set Version_IE='" & y & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)
sSQL="Update nombre Set Version_Windows='" & x & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)
sSQL="Update nombre Set Service_Pack='" & b & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)
sSQL="Update nombre Set Sin_Service_Pack='" & a & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)
sSQL="Update nombre Set Fecha='" & h & "' Where ip='" & ip & "'"
set RS = Conn.Execute(sSQL)


Response.Write( "<TR>" & vbCrlf ) 'ip,software,x,y,xy,a,b
Response.Write( "<p>&nbsp;</p><TD><B>Fecha y hora es : "&h&"</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Tu Ip es: " & ip & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Idioma del Windows es: " & idioma & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Version del Intert Explorer es:" & y & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Version del Sistema Operativo es:" & x & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>" & a & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>" & b & "</B></TD><p></p>" & vbCrlf )
Response.Write( "</TR>" & vbCrlf )

else


'Recogo el formulario de Request.Form("Nombre)
sNombre = Trim(Request.Form("Nombre"))
sDepto = Trim(Request.Form("Depto"))
sArea = Trim(Request.Form("Area"))
'Nombre=request.form("Nombre")
'Si esta variable está vacía
'es que no hemos enviado el formulario
'así que lo muestro
if Len(sNombre) = 0 then

Formulario
else
'Tengo ya un nombre para insertar
'Creo los objetos Connection y Recordset
h= Now()
ip = Request.ServerVariables("REMOTE_ADDR")
idioma = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")
x=request.servervariables("http_user_agent")
str_varserver=request.servervariables("http_user_a gent")
str_temp=mid(str_varserver,instr(str_varserver,"(" )+1)
str_temp=mid(str_temp,1,instr(str_temp,")")-1)
mat=split(str_temp,";")
explorador=mid(str_varserver,1,instr(str_varserver ,"(")-1)+mat(1)
y = explorador
x = trim(mat(2))
xy=len(request.servervariables("http_user_agent"))
if xy<=50 then
a= "No tiene instalado el Service Pack"
else
b = trim(mat(3))


'rs.close
set rs= Nothing
' conn.close
Set conn = Nothing
'Abro el Recordset con la sentencia SQL
'definiendo oConn como el objeto Connection
'y cursor 1 y lock(cerrojo) 2
'Identifica el tipo del Browsner que usa el cliente
'===========================================
'Guardo los cambios
'end if
'================================================= =======
'Imprimo una fila de la tabla
'para cada registro que encuentre
Response.Write( "<TR>" & vbCrlf ) 'ip,software,x,y,xy,a,b
Response.Write( "<p>&nbsp;</p><TD><B>Fecha y hora es : "&h&"</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Tu Ip es: " & ip & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Idioma del Windows es: " & idioma & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Version del Intert Explorer es:" & y & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>Version del Sistema Operativo es:" & x & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>" & a & "</B></TD><p>&nbsp;</p>" & vbCrlf )
Response.Write( "<TD><B>" & b & "</B></TD><p></p>" & vbCrlf )
Response.Write( "</TR>" & vbCrlf )
'Pasamos al siguiente registro
'Olvidarte esto significa que vas a imprimir
'siempre el mismo registro... Un bucle infinito!
'Cierro la tabla
end if
'//////////////////////////////////////////////////////////

' cnn.Open "DSN=mantto"
'sql ="select nombre from ips where ip = & ip "
'sql = "SELECT * FROM nombre WHERE ip='"&ip&"'"
'rs.open sql,conn,1,1


'================================================= =======
End if
Sub Formulario
'Imprimo por pantalla el formulario
Response.Write("<FORM ACTION=""pc.asp"" METHOD=""post"">" & vbCrlf)
Response.Write("<P>Introduce tu nombre:" & vbCrlf)
Response.Write("<INPUT TYPE=""text"" NAME=""Nombre"" SIZE=""50""><p>" & vbCrlf)
Response.Write("<P>Introduce el departamento:" & vbCrlf)
Response.Write("<INPUT TYPE=""text"" NAME=""Depto"" SIZE=""50""><p>" & vbCrlf)
Response.Write("<P>Introduce el area:" & vbCrlf)
Response.Write("<INPUT TYPE=""text"" NAME=""Area"" SIZE=""50""><p>" & vbCrlf)
Response.Write("<INPUT TYPE=""submit"" VALUE=""Enviar"">" & vbCrlf)
Response.Write("</FORM>")
End Sub'Formulario
%>

<%
dim cuenta,actualiza
dns="DSN=pc"
set conn = Server.CreateObject("ADODB.connection")
conn.open(dns)
set rs = server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM nombre WHERE ip='"&ip&"'"
rs.open sql,conn,1,1
if rs.eof = true then
con="insert into nombre (ip,nombre,dept('"&ip&"',' ',' ',' ',1)"
' conn.execute(nombre,area,visito) values
else
' ejecuta la consulta
'cnn.Execute (sql)
set rs = conn.Execute(sql)
end if
if rs.eof = false then
cuenta=rs.Fields("visito")+ 1
actualiza= "Update nombre set visito = '"&cuenta&"' WHERE '"&ip&"'=ip"
set rs = conn.Execute(actualiza)
Response.Write("<B>HAZ ENTRADO A LA PAGINA DE MANTENIMIENTO DE EQUIPO: </B>" & cuenta & " <i>VECES</i>" )
else
cuenta = 1
Response.Write("<B>HAZ ENTRADO A LA PAGINA DE MANTENIMIENTO DE EQUIPO: </B>" & cuenta & " <i>VECES</i>" )
end if
sSQL="insert into nombre (ip,Usuario,depto,area,visito,Idioma,Version_IE,Ve rsion_Windows,Service_Pack,Sin_Service_Pack,Fecha) values ('"&ip&"','"&sNombre&"','"&sDepto&"','"&sArea&"',' "&cuenta&"','"&idioma&"','"&y&"','"&x&"','"&b&"',' "&a&"','"&h&"')"
set RS = conn.Execute(sSQL)
'end if
%>


Pero no me muestra la informacion almacenada si no que otra vez me envia al formulario en que estoy mal
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:46.