<% session.LCID=1040 %> <% Dim conn Dim strSQL Dim rs Dim i,j Dim tmpCODORD Dim arrPROD(100,9) Dim arrQT Dim tmpDATA Dim arrPRODOTTI Dim arrCARR(50000) 'CONTROLLO CI SIA QUALCOSA NEL CARRELLO if request.Cookies("carrello")="" then response.Redirect "/carrello/carrello.asp" end if 'CONTROLLO CHE L'UTENTE ABBIA FATTO IL LOGIN if request.Cookies("codCLIE")="" then response.Redirect "step0.asp" end if tmpDATA=year(now()) if len(month(now()))=1 then tmpDATA=tmpDATA & "0" & month(now()) else tmpDATA=tmpDATA & month(now()) end if if len(day(now()))=1 then tmpDATA=tmpDATA & "0" & day(now()) else tmpDATA=tmpDATA & day(now()) end if 'CREO UN NUOVO RECORD ORDINE strSQL="INSERT INTO ordini (idf_cliente,data_ord,stato_ordine,referrer,host) VALUES (" _ & request.Cookies("codCLIE") & "," & tmpDATA & ",9,'" _ & replace(request.Cookies("referrer"),"'","''") & "','" & request.ServerVariables("REMOTE_ADDR") & "')" set conn=OpenDatabase() Application.Lock() conn.execute(strSQL) strSQL="SELECT max(idp_ordine) FROM ordini" set rs=conn.execute(strSQL) tmpCODORD=rs(0) rs.close Application.UnLock() response.Cookies("codORD")=tmpCODORD 'INSERISCO I PRODOTTI NEL DETTAGLIO ORDINI arrQT=split(request.Cookies("quantita"),",") arrPRODOTTI=split(request.Cookies("carrello"),",") For i=0 to ubound(arrPRODOTTI) arrCARR(arrPRODOTTI(i))=arrQT(i) next strSQL="SELECT p.articolo,p.idp_prodotto,p.prezzo_c,c.categoria,p.offerta,p.idf_categoria,p.peso " _ & "FROM prodotti AS p INNER JOIN categorie AS c " _ & "ON p.idf_categoria=c.idp_categoria WHERE idp_prodotto in (" _ & request.Cookies("carrello") & ")" set rs=conn.execute (strSQL) i=0 do while not rs.eof arrPROD(i,1)=rs("categoria") & " " & rs("articolo") arrPROD(i,2)=rs("prezzo_c") arrPROD(i,3)=rs("idp_prodotto") arrPROD(i,5)=arrCARR(rs("idp_prodotto")) arrPROD(i,8)=rs("offerta") arrPROD(i,9)=rs("peso") rs.movenext i=i+1 loop rs.close set rs=nothing tmpTOTALE=0 for j=0 to i-1 strSQL="INSERT INTO dettaglio_ordini (idf_ordine,prodotto,prezzo,idf_prodotto,quantita,offerta,peso) VALUES (" _ & tmpCODORD & ",'" _ & replace(arrPROD(j,1),"'","''") & "'," _ & replace(arrPROD(j,2),",",".") & "," _ & arrPROD(j,3) & "," _ & arrPROD(j,5) & "," _ & arrPROD(j,8) & "," _ & arrPROD(j,9) & ")" response.write strSQL conn.execute(strSQL) tmpTOTALE=cdbl(tmpTOTALE) + cdbl(arrPROD(j,2))*cint(arrPROD(j,5)) next conn.close set conn=nothing response.Cookies("totPRODOTTI")=replace(tmpTOTALE,",",".") response.Redirect "step1.asp" %>