Salve ragazzi, io purtroppo non so programmare in ASP (mi ci sono avvicinato da poco, ma grazie agli utenti del forum e al sito sono cmq riuscito a creare un collegamnto a un DB, una consolle di inserimento/cancellazione/modifica e un motore di ricerca su due campi. Ora mi è stato chiesto di implementare a tutto ciò un carrello elettronico (il + semplice possibile). Praticamente al proprietario del sito deve arrivare una mail con i dati dell'acquirente, i prodotti e il totale, poi il proprietario provvederà a contattare il cliente.
Io non sono capace e non so se è possibile implementare il carrello alla struttura che ho già costruito o se devo fare tutto ex-novo.
Qualcuno saprebbe indicarmi un tutorial seplice o un carrello precompilato o, a limite, qualcuno che possa aiutarmi (se a prezzi modici anche a pagamento)?
Per completezza vi allego i listati dei file che ho usato:
Pannello gestione DB
codice:
<%
strFile = "zappo.asp"
strTable = "Nomi"
strKey = "ID"
bgHeaderColor = "#990000"
fontHeaderColor = "white"
bgColor1 = "Silver"
fontColor1 = "Black"
bgColor2 = "White"
fontColor2 = "Black"
Set MyConn=Server.CreateObject("ADODB.Connection")
MyConn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/database2.mdb")
Select Case Request("mode")
Case "AddItem"
AddItem
Case "AddItemAction"
AddItemAction
Case "EditItem"
EditItem
Case "EditItemAction"
EditItemAction
Case "DelItem"
delItem
Case Else
ShowAll
End Select
Sub ShowAll()
MySQL="Select * from " & strTable &" ORDER BY Espansione ASC"
Set MyRs=MyConn.Execute(MySQL)
Response.write ("<h2>LISTA COMPLETA by RedOgre</h2>")
Response.write ("
<font size=""2"">AGGIUNGI NUOVO</font></p>")
Response.write ("<table border=""1"" cellpadding=""4"" cellspacing=""1"">")
Response.write ("<tr>")
numerocampi=MyRs.fields.count -1
Response.write ("<td bgcolor=""" & bgHeaderColor & """ align=""Center"" nowrap><font color=""" & fontHeaderColor & """ size=""2"">X</font></td>")
Response.write ("<td bgcolor=""" & bgHeaderColor & """ align=""Center"" nowrap><font color=""" & fontHeaderColor & """ size=""2"">E</font></td>")
for i=0 to numerocampi
if Not MyRs(i).name = "ID" then
Response.write ("<td bgcolor=""" & bgHeaderColor & """ align=""Center"" nowrap><font color=""" & fontHeaderColor & """ size=""2"">" & MyRs(i).name & "</font></td>")
end if
next
Response.write ("</tr>")
do while not MyRs.eof
if bgColor = bgColor2 then
bgColor = bgColor1
fontColor = fontColor1
else
bgColor = bgColor2
fontColor = fontColor2
end if
Response.write ("<tr>")
Response.write ("<td align=""Center"" valign=""Top"" bgcolor=""" & bgColor & """>")
Response.write ("<font color=""" & fontColor & """>Elimina</font></td>")
Response.write ("<td align=""Center"" valign=""Top"" bgcolor=""" & bgColor & """>")
Response.write ("<font color=""" & fontColor & """>Modifica</font></td>")
for i = 0 to numerocampi
if Not MyRs(i).name = "ID" then
if MyRs(i).name = "PRICE" then
ThisRecord = FormatCurrency(MyRs(i))
strAlign = "right"
else
ThisRecord = MyRs(i)
strAlign = ""
end if
If IsNull(ThisRecord) or ThisRecord = "" Then
ThisRecord = ""
end if
ThisRecord = Replace(ThisRecord,vbCrLf,"
")
Response.write ("<td align=""" & strAlign & """ valign=top bgcolor=""" & bgColor & """><font color=""" & fontColor & """>" & Thisrecord & "</font></td>")
end if
next
Response.write ("</tr>")
MyRs.movenext
loop
Response.write ("</table>")
MyRs.close
Set MyRs= Nothing
end sub
Sub AddItem()
MySQL="Select * from " & strTable
Set MyRs=MyConn.Execute(MySQL)
Response.write ("<h2>Aggiungi nuovo Record a " & strTable & "</h2>")
Response.write ("<form action=""" & strFile & "?mode=AddItemAction"" method=""post"" id=form1 name=form1>")
Response.write ("<table>")
numerocampi=MyRs.fields.count -1
for i=0 to numerocampi
if Not MyRs(i).name = "ID" then
ThisRecord = MyRs(i)
ThisRecordName = MyRs(i).name
If IsNull(ThisRecord) or ThisRecord = "" Then
ThisRecord = ""
end if
Response.write ("<tr>")
Response.write ("<td align=""right"">" & ThisRecordName & ": </td>")
Response.write ("<td> <input name=""" & ThisRecordName & """ type=""text""></td>")
Response.write ("</tr>")
end if
next
Response.write ("<tr>")
Response.write ("<td align=""right""><input name=""Submit"" type=submit value=""Submit""></td>")
Response.write ("<td><input name=""reset"" type=reset value=""Reset""></td>")
Response.write ("</tr>")
Response.write ("</table>")
Response.write ("</form>")
Response.write ("Back to list")
End Sub
Sub AddItemAction()
MySQL="Select * from " & strTable
Set MyRs=MyConn.Execute(MySQL)
numerocampi=MyRs.fields.count -1
for i=0 to numerocampi
if Not MyRs(i).name = "ID" then
str = MyRs(i).name
if not i = numerocampi then
str1 = str1 & "[" & str & "], "
else
str1 = str1 & "[" & str & "]"
end if
strNames = Request(str)
if not i = numerocampi then
sqlNames1 = sqlNames1 & "'" & strNames & "', "
else
sqlNames1 = sqlNames1 & "'" & strNames & "'"
end if
end if
next
MySQL1="Insert INTO " & strTable & " (" & str1 & ") VALUES (" & sqlNames1 & ")"
Set MyRs1=MyConn.Execute(MySQL1)
MyConn.Close
set MyConn=nothing
Response.Redirect strFile
End Sub
Sub EditItem()
Response.write ("<h2>Modifica record nella tabella " & strTable & "</h2>")
which=request("which")
if isNumeric(which) then
MySQL="SELECT * FROM " & strTable & " Where " & strKey & " = " & which
else
MySQL="SELECT * FROM " & strTable & " Where " & strKey & " = '" & which & "'"
end if
Set MyRs=MyConn.Execute(MySQL)
Response.write ("<FORM ACTION=""" & strFile & "?mode=EditItemAction"" METHOD=POST>")
Response.write ("<input name=""ID"" type=""hidden"" value=""" & MyRs(strKey) & """>")
Response.write ("<table>")
numerocampi=MyRs.fields.count -1
for i=0 to numerocampi
if Not MyRs(i).name = "ID" then
ThisRecord = MyRs(i)
ThisRecordName = MyRs(i).name
If IsNull(ThisRecord) or ThisRecord = "" Then
ThisRecord = ""
end if
Response.write ("<tr>")
Response.write ("<td align=""right"">" & ThisRecordName & ": </td>")
Response.write ("<td> <input name=""" & ThisRecordName & """ type=""text"" value=""" & MyRs(i) & """></td>")
Response.write ("</tr>")
end if
next
Response.write ("<tr>")
Response.write ("<td align=""right""><INPUT NAME=""Submit"" TYPE=Submit Value=""Update""></td>")
Response.write ("<td><INPUT NAME=""Reset"" TYPE=Reset Value=""Reset""></td>")
Response.write ("</tr>")
Response.write ("</table>")
Response.write ("</FORM>")
Response.write ("Torna alla lista dei record")
MyRs.close
Set MyRs= Nothing
End Sub
Sub EditItemAction()
which = Request(strKey)
if isNumeric(which) then
MySQL="SELECT * FROM " & strTable & " Where " & strKey & " = " & which
else
MySQL="SELECT * FROM " & strTable & " Where " & strKey & " = '" & which & "'"
end if
'MySQL="Select * from " & strTable
Set MyRs=MyConn.Execute(MySQL)
numerocampi=MyRs.fields.count -1
for i=0 to numerocampi
if Not MyRs(i).name = "ID" then
str = MyRs(i).name
strNames = Request(str)
if not i = numerocampi then
str1 = str1 & "[" & str & "] = '" & strNames & "', "
else
str1 = str1 & "[" & str & "] = '" & strNames & "'"
end if
end if
next
if isNumeric(which) then
MySQL1="UPDATE " & strTable & " SET " & str1 & " Where " & strKey & " = " & which
else
MySQL1="UPDATE " & strTable & " SET " & str1 & " Where " & strKey & " = '" & which & "'"
end if
'MySQL1="UPDATE " & strTable & " SET " & str1 & " Where ID=" & which
Set MyRs1=MyConn.Execute(MySQL1)
MyConn.Close
set MyConn=nothing
Response.Redirect strFile
End Sub
Sub DelItem()
which=request("which")
if isNumeric(which) then
MySQL="delete * from " & strTable & " Where " & strKey & " = " & which
else
MySQL="delete * from " & strTable & " Where " & strKey & " = '" & which & "'"
end if
Set MyRs=MyConn.Execute(MySQL)
MyConn.Close
set MyConn=nothing
Response.Redirect strFile
End Sub
%>
---------------------------------------------------------------------
Motore di ricerca:
<form action="risultati.asp" method="POST">
<p align="center"><font color="#990000">Inserisci il nome della
carta:</font></p>
<p align="center">
<input type="text" name="Nome">
<input type="submit" value="CERCA">
</p>
</form>
---------------------------------------------------------------------
Pagina risultati:
<%@ LANGUAGE = JScript %> <%
var testo = String(Request.Form("Nome"));
if (testo=="" || testo=="undefined") Response.Redirect("ricerca_carte.htm");
var Nome = testo.split(" ");
var stringaDiConnessione = "driver={Microsoft Access Driver (*.mdb)};dbq=";
stringaDiConnessione += Server.MapPath("/mdb-database/database2.mdb");
var conn = new ActiveXObject("ADODB.Connection");
conn.Open(stringaDiConnessione);
%>
<table border="0" cellpadding="0" cellspacing="20"><tr><td>Nome</td><td>Nome Inglese</td><td>Espansione</td><td>Colore</td><td>Rarità</td><td>Prezzo</td><td>Disponibili</td><td>Foto</td></tr>
<%
var sql = "SELECT * FROM Nomi WHERE";
for (i=0;i<Nome.length;i++) {
if (i>0) sql += " AND";
sql += " Nome LIKE '%" + Nome[i] + "%' OR [Nome Inglese] LIKE '%" + Nome[i] + "%'";
}
var ris = conn.Execute(sql);
if (ris.EOF)
%>
SPIACENTE, CARTA NON PRESENTE
<%
else while (!ris.EOF) {
%>
<tr>
<td><%=ris("Nome")%></td>
<td><%=ris("Nome Inglese")%></td>
<td><%=ris("Espansione")%></td>
<td><%=ris("Colore")%></td>
<td><%=ris("Rarità")%></td>
<td><%=ris("Prezzo")%></td>
<td><%=ris("Qt")%></td>
<td>">clicca qui</td>
</tr>
<%
ris.MoveNext();
}
%>
</table>
<%
conn.Close();
%>
Grazie mille anticipatamente a tutti coloro che mi aiuteranno!