Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    come prelevare i dati di una form e inserirli in una email

    Salve a tutti, premetto che non sono una cima in asp, me a cavicchio solo.
    Ho cercato nel forum ma non ho trovato la risposta al mio problema, quindi ecco quà:
    sto cercando di realizzare per un amico un piccolo shop on-line senza troppe pretese (niente pagamenti con carte di credito ma solo in contrassegno postale). Ho trovato un esempio molto semplice di carrello eletronico su www.asp101.com che fa esattamente quello che vogliamo. Quando si accede all'elenco dei prodotti nel carrello ho inserito un form per richiedere i dati del cliente per la fatturazione/spedizione della merce. Una volta immessi i dati, e dato conferma dell'ordine, mi viene spedita una mail con l'ordine e i dati del cliente.
    Tutto funziona, solo che nel corpo della mail vene riportato l'elenco dei prodotti richiesti, ma non i dati del cliente.
    Mi potete aiutare?

    Ecco parte del listato con l'inserimento dati cliente (non metto tutto il listato perché è un poco lungo):

    <table width="698" border="0" cellpadding="3" cellspacing="1" class="style1">
    <tr>
    <td width="66">Codice</td>
    <td width="180">Nome prodotto</td>
    <td width="58">Quantit&agrave;</td>
    <td width="186">Rimuovi l'articolo dal carrello </td>
    <td width="80">Prezzo</td>
    <td width="71">Totale</td>
    </tr>
    <%
    sTotal = 0
    For Each objKey in dictCart
    aParameters = GetItemParameters(objKey)
    %>
    <tr>
    <td align="center"><%= objKey %></td>
    <td align="left"><%= aParameters(1) %></td>
    <td align="center"><%= dictCart(objKey) %></td>
    <td align="left">Uno
    Tutti</td>
    <td align="right">&euro;<%= aParameters(2) %></td>
    <td align="right">&euro;<%= FormatNumber(dictCart(objKey) * CSng(aParameters(2)), 2) %></td>
    </tr>
    <%
    sTotal = sTotal + (dictCart(objKey) * CSng(aParameters(2)))
    Next

    ' Calculate shipping
    sShipping = CalculateShippingCost(sTotal)

    ' Add shipping to total
    sTotal = sTotal + sShipping
    %>
    <tr>
    <td colspan="5" align="right">Spese di spedizione :</td>
    <td align="right">&euro;<%= FormatNumber(sShipping, 2) %></td></tr>
    <tr>
    <td colspan="5" align="right">Totale:</td>
    <td align="right">&euro;<%= FormatNumber(sTotal, 2) %></td></tr>
    </table>
    <p class="style2">Destinatario merce e fattura</p>
    <form action="shopping.asp?id=" method="post" name="cliente" id="cliente">
    <table width="513" border="0" class="style1">
    <tr>
    <td colspan="2" align="center"><div align="left">Si prega di compilare tutti i campi, altrimenti l'ordine non sar&agrave; ritenuto valido.</div></td>
    </tr>
    <tr>
    <td width="122"></td>
    <td width="381"></td>
    </tr>
    <tr>
    <td align="right">Nome:</td>
    <td><input name="nome" type="text" id="nome" size="40" maxlength="50"></td>
    </tr>
    <tr>
    <td align="right">Cognome:</td>
    <td><input name="cognome" type="text" id="cognome" size="40" maxlength="50"></td>
    </tr>
    <tr>
    <td align="right">Codice fiscale/P.Iva:</td>
    <td><input name="cf" type="text" id="cf" size="40" maxlength="50"></td>
    </tr>
    <tr>
    <td align="right">Indirizzo:</td>
    <td><input name="indirizzo" type="text" id="indirizzo" size="40" maxlength="80"></td>
    </tr>
    <tr>
    <td align="right">Citt&agrave;:</td>
    <td><input name="citta" type="text" id="citta" size="40" maxlength="50"></td>
    </tr>
    <tr>
    <td align="right">Provincia:</td>
    <td><input name="provincia" type="text" id="provincia" size="40" maxlength="50"></td>
    </tr>
    <tr>
    <td align="right">Telefono:</td>
    <td><input name="telefono" type="text" id="telefono" size="40" maxlength="50"></td>
    </tr>
    </table>
    </form>

    Mentre i pulsanti in fondo alla pagina sono questi:

    [img]images/shop_look.gif[/img]
    [img]images/shop_checkout.gif[/img]

    Ora passiamo all'invio dell'email:

    Dim objMessage, strMessageBody

    strMessageBody = "Quantita' Codice Nome prodotto Prezzo Totale" & vbCrLf & vbCrLf

    For Each objKey in dictCart
    aParameters = GetItemParameters(objKey)
    strMessageBody = strMessageBody & " " & dictCart(objKey)
    strMessageBody = strMessageBody & " " & objKey
    strMessageBody = strMessageBody & " " & aParameters(1)
    strMessageBody = strMessageBody & String(25 - Len(aParameters(1)), " ") & aParameters(2)
    strMessageBody = strMessageBody & " " & FormatNumber(dictCart(objKey) * CSng(aParameters(2)), 2) & vbCrLf

    Next
    strMessageBody = strMessageBody & vbCrLf
    strMessageBody = strMessageBody & String(30, " ") & "Spese di spedizione: " & FormatNumber(sShipping, 2) & vbCrLf
    strMessageBody = strMessageBody & vbCrLf
    strMessageBody = strMessageBody & String(39, " ") & "Totale: " & FormatNumber(sTotal, 2) & vbCrLf
    strMessageBody = strMessageBody & vbCrLf
    strMessageBody = strMessageBody & "Dati fattutazione/spedizione" & vbCrLf
    strMessageBody = strMessageBody & "Cognome: " & Request.Form("cognome") & vbCrLf
    strMessageBody = strMessageBody & "Nome:" & Request.Form("nome") & vbCrLf
    strMessageBody = strMessageBody & "C.F./P.IVA:" & Request.Form("cf")

    'Response.Write "<pre>" & strMessageBody & "</pre>"

    Set objMessage = Server.CreateObject("CDO.Message")
    With objMessage
    ' Set message attributes
    .To = "pippo<pippo@pippo.it>"
    .From = "pippo<pippo@pippo.it>"
    .Subject = "Nuovo ordine"
    .TextBody = strMessageBody
    ' Send message - uncomment the following line only
    ' AFTER you've entered appropriate To and From
    ' addresses above. Then the script will actually
    ' send the messages.
    .Send
    End With
    Set objMessage = Nothing

  2. #2
    C'è nessuno che può darmi qualche suggerimento?
    Almeno dirmi dove sto sbagliando?
    Il listato completo dell'esempio lo si può vedere su asp101.com/samples/shopping.asp
    Grazie

  3. #3
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Il punsante a fondo pagina deve essere un input type="submit" prima del </form>, non un semplice link altrimenti i dati del form (nome, cognome, ecc...) non li passi all'altra pagina e quindi un ipotetico

    Request.Form("cognome")

    non recupera nulla.

    Roby

  4. #4
    Ok, ci provo a trasformare il pulsante. Scusami, ma sono proprio una novizia in asp. Il listato sembrava semplice e così ho detto che potevo darli una mano.
    Grazie Grazie!!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.