Træk data ud fra database
Til ASP eksperterneJeg har dette verify.asp dokument. Det der sker er at dokumentet slår op i en database og skriver til en mail der så bliver sendt til mig via Jmail, alle ting virker fint, der er dog dette problem her.
Jeg kan ikke få den til at tage catalogid med her er scriptet, hvordan får jeg den til at tage catalogid med ? :
<%@ Language=VBScript %>
<!-- #include file=\"db.inc\" -->
<%
For Each key in Request.Form
strname = key
strvalue = Request.Form(key)
Session(strname) = strvalue
Next
If Request.Form(\"cardaddress\") = \"\" OR len(Request.Form(\"cardaddress\")) <=8 Then
Response.Redirect \"checkout.asp?msg=\" & Server.URLEncode (\"Skriv venligst en adresse som vi kan sende en kvittering til.\")
Else
Dim arrCart, metacartItem
arrCart = Session(\"MyCart\")
metacartItem = Session(\"cartItem\")
Dim rsorder
Set rsorder = Server.CreateObject (\"ADODB.recordset\")
strBody = strBody & \"Kundens fornavn : \" & Session(\"fname\") & vbCrLf
strBody = strBody & \"Kundens efternavn : \" & Session(\"lname\") & vbCrLf
strBody = strBody & \"Kundens e-post : \" & Session(\"email\") & vbCrLf
strBody = strBody & \"Kundens adresse : \" & Session(\"address\") & vbCrLf
strBody = strBody & \"Kundens by / bygd : \" & Session(\"town\") & vbCrLf
strBody = strBody & \"Kundens post nr : \" & Session(\"state\") & vbCrLf
strBody = strBody & \"Ønsket leverings dato : \" & Session(\"zip\") & vbCrLf
strBody = strBody & \"Ønsket leverings dato : \" & Session(\"country\") & vbCrLf
strBody = strBody & \"Kundens telefon nr : \" & Session(\"phone\") & vbCrLf
strBody = strBody & \"Antal af hver : \" & Session(\"quantity\") & vbCrLf
strBody = strBody & \"Kunde ID : \" & Session(\"customerid\") & vbCrLf
strBody = strBody & \"Ordre dato : \" & Date & vbCrLf
strBody = strBody & \"Beløb i alt: \" & Request.Form(\"ordertotal\") & vbCrLf
strBody = strBody & \"Forsendelse: \" & CInt(Request.Form(\"shipment\")) & vbCrLf & vbCrLf
strBody = strBody & \"Kvittering sendes til: \" & Request.Form(\"cardaddress\") & vbCrLf & vbCrLf
strBody = strBody & \"HVIS LEVERING TIL ANDEN END KUNDE SELV\" & vbCrLf & vbCrLf
rsorder.Open \"orders\", dbc, adOpenKeyset, adLockPessimistic, adCmdTable
rsorder.AddNew
rsorder(\"ocustomerid\") = Session(\"customerid\")
rsorder(\"odate\") = Date
rsorder(\"orderamount\") = Request.Form(\"ordertotal\")
rsorder(\"oshipmethod\") = CInt(Request.Form(\"shipment\"))
rsorder(\"ocardtype\") = Request.Form(\"paymentm\")
rsorder(\"ocardno\") = Request.Form(\"cardno\")
rsorder(\"ocardname\") = Request.Form(\"cardname\")
rsorder(\"ocardexpires\") = Request.Form(\"cardexpire\")
rsorder(\"ocardaddress\") = Request.Form(\"cardaddress\")
If Not Request.Form(\"shipaddress\") = \"\" Then rsorder(\"oshipaddress\") = Request.Form(\"shipaddress\"): strBody = strBody & \"Addresse: \" & Request.Form(\"shipaddress\") & vbCrLf
If Not Request.Form(\"shiptown\") = \"\" Then rsorder(\"oshiptown\") = Request.Form(\"shiptown\"): strBody = strBody & \"By / bygd: \" & Request.Form(\"shiptown\") & vbCrLf
If Not Request.Form(\"shipzip\") = \"\" Then rsorder(\"oshipzip\") = Request.Form(\"shipzip\"): strBody = strBody & \"Leverings dato: \" & Request.Form(\"shipzip\") & vbCrLf
If Not Request.Form(\"shipstate\") = \"\" Then rsorder(\"oshipstate\") = Request.Form(\"shipstate\"): strBody = strBody & \"Postnummer: \" & Request.Form(\"shipstate\") & vbCrLf
If Not Request.Form(\"shipcountry\") = \"\" Then rsorder(\"oshipcountry\") = Request.Form(\"shipcountry\"): strBody = strBody & \"Leverings tidspunkt: \" & Request.Form(\"shipcountry\") & vbCrLf
rsorder.Update
rsorder.Close
Dim oid, sqlo
sqlo = \"SELECT max(orderID) FROM orders\"
Set rso = dbc.Execute(sqlo)
oid = Cint(rso(0))
rso.Close
If oid < 1 Then
Response.Redirect \"error.asp?msg=\" & Server.URLEncode (\"Error: No order id.\")
Else
Dim rsitem
Set rsitem = Server.CreateObject (\"ADODB.recordset\")
rsitem.Open \"oitems\", dbc, adOpenKeyset, adLockOptimistic , adcmdtable
For i = 1 To metacartItem
rsitem.AddNew
rsitem(\"orderid\") = oid
rsitem(\"catalogid\") = arrCart(cProductid,i)
rsitem(\"numitems\") = arrCart(cQuantity,i)
rsitem.Update
Next
rsitem.Close
End if
If dbc.Errors.Count > 0 then
dbc.Close
set dbc = nothing
Response.Redirect \"error.asp?msg=\" & Server.URLEncode (\"Did not succeed. Error: \") & dbc.Error.Description
Else
dbc.close
set dbc = nothing
Set JMail = Server.CreateObject(\"JMail.SMTPMail\")
JMail.ServerAddress = \"mail.kni.gl\"
JMail.Sender = \"arz@mail.kni.gl\"
JMail.Sendername = \" SPAR Vinhandel \"
JMail.Subject = \" Ny Ordre \"
\' **** Modtager af e-mailen ( f.eks. din@email.dk ) ************
JMail.AddRecipient \"arz@mail.kni.gl\"
JMail.Body = strBody
JMail.Priority = 3
JMail.AddHeader \"Originating-IP\", Request.ServerVariables(\"REMOTE_ADDR\")
\' **** Sender E-Mailen ************
JMail.Execute
\'********** her afsluttes Jmail ******
Response.Redirect \"checkout1.asp\"
End If
End If
%>
