Ho notato che in veditutto.asp c'era questa if :
- if Request.Querystring("Tipo_Contatto") = "Amici" then
che faceva riferimento a querystring e non al record appena letto per cui penso debba essere :
- if rs("Tipo_Contatto") = "Amici" then
Forse era questo l'errore. Veniva sempre generato lo stesso pezzo di pagina, senza tener conto del record letto.
Inoltre hai usato p.es.: cognome=request("cognome").
E' corretto ? io conosco request.querystring... oppure request.form..., ma request da sola come istruzione non la ho mai vista. Forse è stato un errore di trascrizione nel postare il file prova.txt.
Inoltre io non uso mai ELSEIF, rischio di confondermi e non sapere più cosa fa il programma. Non solo, chiudo ogni if con la sua end if ed il contenuto di ogni nodo di if lo sposto verso destra in modo da poter capire anche visivamente in quale situazione mi trovo.
Ho apportato qualche piccola modifica in base a quello che dicevo :
codice:
' ------------------------------------------------------------------------------------------------
' PAGINA: ritultato.asp
' ------------------------------------------------------------------------------------------------
<!--#include file="conn.asp" -->
<%
Response.Expires = -20000 'Makes the browser not cache this page
Response.Buffer = True 'Buffers the content so our Response.Redirect will work
If Session("UserLoggedIn") <> "true" Then
Response.Redirect("index.asp")
End If
titolo=request("titolo")
cognome=request("cognome")
nome_parente=request("nome")
indirizzo=request("indirizzo")
telefono_casa=request("telefono_casa")
telefono_ufficio=request("telefono_ufficio")
telefono_2=request("telefono_2")
cellulare1=request("cellulare1")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Driver={MySQL ODBC 3.51 Driver};SERVER=xxx.xxx.xxx.xxx;Database=Sqlxxxxx_x;port=xxxx;UID=Sqlxxx;PWD=xxxx;"
Sql = "SELECT * from anagrafica where titolo like '"&titolo&"%' and cognome like '"&cognome&"%' ... "
set rs=conn.execute(Sql)
%>
..
<a href="veditutto.asp?progressivo=<%=rs("progressivo")%>&Tipo_Contatto=<%=rs("tipologia")%>">
<img border="0" src="../../immagini_rubrica/vedi.png" alt="Mostra scheda <%=sContatto%>">Vedi</a>
.....
' ------------------------------------------------------------------------------------------------
' PAGINA: veditutto.asp
' ------------------------------------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="conn.asp" -->
<%
session("progressivo")=request("progressivo")
Sql = "SELECT * from anagrafica "
set rs=conn.execute(Sql)
%>
...
<%
if rs("Tipo_Contatto") = "Amici" then
%>
..
<td width="233" align="right" nowrap bgcolor="#FFFFCC">
<div align="right">
<font size="2">
<strong><font color="#003366" face="Tahoma">Cognome:</font></strong></font></div>
</td>
<td width="248" height="19" bgcolor="dddddd"> <font color="#003366" size="2" face="Tahoma">
<%=rs("cognome")%> </font></td>
...
<%
else
if rs("Tipo_Contatto") = "Parenti" then
%>
...
<td width="233" align="right" nowrap bgcolor="#FFFFCC">
<div align="right"><font size="2">
<strong><font color="#003366" face="Tahoma">Parente:</font></strong></font></div></td>
<td width="248" height="19" bgcolor="dddddd"> <font color="#003366" size="2" face="Tahoma"><%=rs("nome_parente")%> </font></td>
<% end if
end if %>
I programmi asp sono tutti concatenati tra di loro e molto spesso l'errore sta nel passaggio dei dati tra una pagina ed un'altra. Per questo mi sono scritto una pagina che mi consente di visualizzare i dati che vengono inviati e che devono rappresentare il mio input nella pagina chiamata. La ho chiamata Vedi_Variabili.asp ed in caso di malfunzionamento la sostituisco a quella realmente chiamata in modo da poter controllare quali sono realmente i dati che vengono trasferiti tra una pagina e l'altra
codice:
<html>
<body>
<%
Server.ScriptTimeout = 3600
Session.Contents("NomePagina") = "..\Pgm\Vedi_Variabili.asp"
'
' 5 Novembre 2010.
' Ultimo Aggiornamento 5 Novembre 2010.
'
' Mostra le variabili con cui viene chiamata
%>
<table border="2" width="100%">
<tr>
<td colspan="7" align=center style="font-size: 14 pt; font-weight: bold; color: #0000FF">..\pgm\Vedi_Variabili.asp</td>
</tr>
<tr>
<% if Request.Querystring.count = 0 then %>
<td colspan="7" align=center style="font-size: 14 pt; font-weight: bold; color: #FF0000">Non ci sono variabili dell'istanza Request.Querystring</td>
<% else %>
<td colspan="7" align=center style="font-size: 14 pt; font-weight: bold; color: #00F000">Ecco le <%=Request.Querystring.count%> variabili dell'istanza Request.Querystring : </td>
</tr>
<tr>
<td colspan="1" Rowspan="2" align=center style="font-size: 12 pt; font-weight: bold; color: #00F000">Numero</td>
<td colspan="1" align=center style="font-size: 12 pt; font-weight: bold; color: #FF0000">Variabile</td>
<td colspan="5" align=center style="font-size: 12 pt; font-weight: bold; color: #0000FF">Contenuto</td>
</tr>
<tr>
<td colspan="1" align=center style="font-size: 12 pt; font-weight: bold; color: #FF0000">Request.Querystring.key(Numero)</td>
<td colspan="5" align=center style="font-size: 12 pt; font-weight: bold; color: #0000FF">Request.Querystring(Numero) oppure Request.Querystring("Variabile")</td>
</tr>
<% num = 1
While num <= Request.Querystring.count
if Request.Querystring(num) = "" then
variabile = " "
else
variabile = Request.Querystring(num)
end if
%>
<tr>
<td colspan="1" align=right style="font-size: 8 pt; font-weight: bold; color: #00F000"><%=num%></td>
<td colspan="1" style="font-size: 8 pt; font-weight: bold; color: #FF0000"><%=Request.Querystring.key(num)%></td>
<td colspan="5" style="font-size: 8 pt; font-weight: bold; color: #0000FF"><%=variabile%></td>
</tr>
<% num=num+1
Wend
end if
%>
<tr>
<% if Request.Form.count = 0 then %>
<td colspan="7" align=center style="font-size: 14 pt; font-weight: bold; color: #FF0000">Non ci sono variabili dell'istanza Request.Form</td>
<% else %>
<td colspan="7" align=center style="font-size: 14 pt; font-weight: bold; color: #00F000">Ecco le <%=Request.Form.count%> variabili dell'istanza Request.Form : </td>
</tr>
<tr>
<td colspan="1" Rowspan="2" align=center style="font-size: 12 pt; font-weight: bold; color: #00F000">Numero</td>
<td colspan="1" align=center style="font-size: 12 pt; font-weight: bold; color: #FF0000">Variabile</td>
<td colspan="5" align=center style="font-size: 12 pt; font-weight: bold; color: #0000FF">Contenuto</td>
</tr>
<tr>
<td colspan="1" align=center style="font-size: 12 pt; font-weight: bold; color: #FF0000">Request.Form.key(Numero)</td>
<td colspan="5" align=center style="font-size: 12 pt; font-weight: bold; color: #0000FF">Request.Form(Numero) oppure Request.Form("Variabile")</td>
</tr>
<% num = 1
While num <= Request.Form.count
if Request.Form(num) = "" then
variabile = " "
else
variabile = Request.Form(num)
end if
%>
<tr>
<td colspan="1" align=right style="font-size: 8 pt; font-weight: bold; color: #00F000"><%=num%></td>
<td colspan="1" style="font-size: 8 pt; font-weight: bold; color: #FF0000"><%=Request.Form.key(num)%></td>
<td colspan="5" style="font-size: 8 pt; font-weight: bold; color: #0000FF"><%=variabile%></td>
</tr>
<% num=num+1
Wend
end if
%>
<table cellspacing=1 cellpadding=4 border=1>
<tr>
<th>Session Variable Name</th>
<th>Session Variable Value</th>
</tr>
<% for i = 0 to session.contents.count %>
<tr>
<td> <%= session.Contents.key(i) %></td>
<td> <%= session.Contents.item(i) %></td>
</tr>
<% next %>
</table>
</table>
</body>
</html>