Scritto da: ~=€MM@=~ 04/05/2006 17.22
stavo creando un sito in asp, ma ho 2 problemi:
1. non mi funziona una query di inserimento
2. non mi funziona la ricerca
form di iscrizione:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script language="javascript">
function verificaCampi(){
if (document.compila.user.value=="") {
alert("Il campo username è obbligatorio!");
return false;
}
if (document.compila.pw.value=="") {
alert("Il campo password è obbligatorio!");
return false;
}
if (document.compila.mail.value=="") {
alert("Il campo email è obbligatorio!");
return false;
}
else if (document.compila.mail.value.indexOf ('@',0) == -1
|| document.compila.mail.value.indexOf ('.',0) == -1){
alert("Il campo email deve contenere i caratteri '@' e '.'")
return false;
}
else
return true;
}
</SCRIPT>
</head>
<body>
<form method="POST" action="iscriviti.asp" name=compila onSubmit="return verificaCampi();">
<table border="0" width="45%">
<tr>
<td width="50%">Username*</td>
<td width="50%"><input type="text" name="user" size="20"></td>
</tr>
<tr>
<td width="50%">Password*</td>
<td width="50%"><input type="password" name="pw" size="20"></td>
</tr>
<tr>
<td width="50%">E-mail*</td>
<td width="50%"><input type="text" name="mail" size="20"></td>
</tr>
<tr>
<td width="50%">Nome</td>
<td width="50%"><input type="text" name="nome" size="20"></td>
</tr>
<tr>
<td width="50%">Cognome</td>
<td width="50%"><input type="text" name="cognome" size="20"></td>
</tr>
<tr>
<td width="50%">Sesso</td>
<td width="50%">
<table align=center border="0" width="80%">
<tr>
<td align=center width="50%">M<input type="radio" value="m" name="sex"></td>
<td align=center width="50%">F<input type="radio" name="sex" value="f"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="50%">Indirizzo</td>
<td width="50%"> <table border="0" width="80%">
<tr>
<td align=center width="50%"><input type="text" name="via" size=15></td>
<td align=center width="50%">N°<input type="text" name="nc" size=3></td>
</tr></table></td>
</tr>
<tr>
<td width="50%">Città</td>
<td width="50%"><input type="text" name="citta" size="20"></td>
</tr>
<tr>
<td width="50%">Codice Fiscale</td>
<td width="50%"><input type="text" name="codfisc" size="20"></td>
</tr>
<tr>
<td width="50%">Telefono</td>
<td width="50%"><input type="text" name="telefono" size="20"></td>
</tr>
</table>
</td>
</tr>
</table>
<p><input type="submit" value="Invia"><input type="reset" value="Cancella tutti i campi" name="reset"></p>
</form>
<p>I CAMPI CONTRASSEGNATI DA * SONO OBBLIGATORI</p>
</body>
</html>
iscriviti.asp
<html>
<head>
<title>Index</title>
</head>
<!--#include file="db.asp"-->
<body>
<%
SQL="INSERT INTO cliente (nome, cognome, via, ncivico, citta, telefono, codfiscale, email, sesso, password, username, tipo) VALUES ('"& request.form("nome") &"', '"& request.form("cognome") &"', '"& request.form("via") &"', '"& request.form("nc") &"', '"& request.form("citta") &"','"& request.form("telefono") &"', '"& request.form("codfisc") &"', '"& request.form("mail") &"', '"& request.form("sex") &"', '"& request.form("pw") &"', '"& request.form("user")&"', utente)"')"
response.write(sql)
set Rs = db.execute(sql)
response.redirect "index.htm"
%>
</body>
</html>
cosa c'è di sbagliato?
form di ricerca:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<!--#include file="db.asp"-->
<body>
<form method="POST" action="cerca.asp">
<%sql="select DISTINCT tipo FROM articolo"
set rs=db.execute(sql)%>
<table border="0">
<tr>
<td>Tipologia</td>
<td><select size="1" name="tipo">
<option value="Tutte" selected>Qualsiasi tipologia</option>
<%while not rs.eof%>
<option value='<%=rs("tipo")%>'> <%=rs("tipo")%> </option>
<%rs.movenext
wend%>
</select></td>
</tr>
<%sql="select DISTINCT prezzo FROM articolo"
set rs=db.execute(sql)%>
<tr>
<td>Prezzo</td>
<td><input type="text" name="prezzo" size="6"></td>
</tr>
</tr>
<%sql="select DISTINCT colore FROM articolo"
set rs=db.execute(sql)%>
<tr>
<td>Colore</td>
<td><select size="1" name="tipo">
<option value="Tutte" selected>Qualsiasi colore</option>
<%while not rs.eof%>
<option value='<%=rs("colore")%>'> <%=rs("colore")%> </option>
<%rs.movenext
wend%>
</select></td>
</tr>
<%sql="select DISTINCT taglia FROM articolo"
set rs=db.execute(sql)%>
<tr>
<td>Taglia</td>
<td><select size="1" name="tipo">
<option selected value="Tutte">Qualsiasi taglia</option>
<%while not rs.eof%>
<option value='<%=rs("taglia")%>'> <%=rs("taglia")%> </option>
<%rs.movenext
wend%>
</select></td>
</tr>
<%sql="select DISTINCT marca FROM articolo"
set rs=db.execute(sql)%> <tr>
<td>Marca</td>
<td><select size="1" name="marca">
<option selected value="Tutte">Qualsiasi marca</option>
<%while not rs.eof%>
<option value='<%=rs("marca")%>'> <%=rs("marca")%> </option>
<%rs.movenext
wend%>
</select></td>
</tr>
</table>
<p><input type="submit" value="Invia" name="invio"><input type="reset" value="Cancella tutti i campi" name="reset"></p>
</form>
</body>
</html>
cerca.asp:
<html>
<head>
<title>Index</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<!--#include file="db.asp"-->
<body>
<%
if request.form("tipo") = "Tutte" then
tipo = "%"
else
tipo = request.form("tipo")
End if
%>
<%
if request.form("prezzo") = "" then
prezzo = "%"
else
prezzo = request.form("prezzo")
End if
%>
<%
if request.form("colore") = "Tutte" then
colore = "%"
else
colore = request.form("colore")
End if
%>
<%
if request.form("taglia") = "Tutte" then
taglia = "%"
else
taglia = request.form("taglia")
End if
%>
<%
if request.form("marca") = "Tutte" then
marca = "%"
else
marca = request.form("marca")
End if
%>
<%
SQL="SELECT * FROM articolo where colore like " & "'" & colore & "'"
set Rs = db.execute(sql) %>
<h1> Gli articoli trovati sono:</h1>
<table width="90%" border="0">
<tr>
<td align=center >
<h3>Codice</h3>
</td>
<td align=center>
<h3>Tipo</h3>
</td>
<td align=center>
<h3>Prezzo</h3>
</td>
<td align=center>
<h3>Colore</h3>
</td>
<td align=center>
<h3>Taglia</h3>
</td>
<td align=center>
<h3>Marca</h3>
</td>
<td align=center>
<h3>Disponibilità</h3>
</td>
<td> <h3>Foto</h3>
</td>
</tr>
</tr>
<% do while not Rs.eof
response.write("<td align=center>"& Rs("codice") & "</td>")
response.write("<td align=center>"& Rs("tipo") & "</td>")
response.write("<td align=center>"& Rs("prezzo") & "</td>")
response.write("<td align=center>"& Rs("colore") & "</td>")
response.write("<td align=center>"& Rs("taglia") & "</td>")
response.write("<td align=center>"& Rs("marca") & "</td>")
response.write("<td align=center>"& Rs("disponibilita") & "</td>")
response.write("<td align=center><img src="& Rs("foto") & " height=50 width=50></td></tr>")
Rs.movenext
loop
Rs.close
%></table >
</body>
</html>
qualcuno saprebbe aiutarmi?
(non spaventatevi x le skifezze nel codice ma di asp non so nulla )
grazie x la disponibilità