I'm trying to make a page that updates a recordset in a ms access database, the same data must also be send to an email address, I'm using dreamweaver to create asp pages, but dreamweaver has limited functions with asp so I have to modify the code by hand, until sofar this is what i have, but it does not work:
Can anyone help me out with this?
code:
'First lets Dim all the variables we need
Dim U_Mail
Dim U_Body
Dim U_Company
Dim U_Phone
Dim U_PhoneExt
Dim U_PhoneMobile
Dim U_Fax
Dim U_Email
Dim U_Address
Dim U_Amphur
Dim U_Tambon
Dim U_Province
Dim U_PostalCode
Dim U_AltPhone
Dim U_AltPhoneExt
Dim U_EmPrefix
Dim U_EmName
Dim U_EmPhone
'Now lets get some values for the variables from the form
U_Company = Request.Form("company")
U_Phone = Request.Form("phone")
U_PhoneExt = Request.Form("phone_ext")
U_PhoneMobile = Request.Form("phone_mobile")
U_Fax = Request.Form("fax")
U_Email = Request.Form("email")
U_Address = Request.Form("address")
U_Amphur = Request.Form("amphur")
U_Tambon = Request.Form("tambon")
U_Province = Request.Form("province")
U_PostalCode = Request.Form("postalcode")
U_AltPhone = Request.Form("alt_phone")
U_AltPhoneExt = Request.Form("alt_phone_ext")
U_EmPrefix = Request.Form("em_prefix")
U_EmName = Request.Form("em_name")
U_EmPhone = Request.Form("em_phone")
'Now lets build the body of the email from the data in the form
U_Body = "Company: "& U_Company & vbcrlf
U_Body = U_Body & "Phone: "& U_Phone & "Ext: "& U_PhoneExt & vbcrlf & vbcrlf
U_Body = U_Body & "Phone mobile: "& U_PhoneMobile & vbcrlf
U_Body = U_Body & "Alternative phone number: "& U_AltPhone & U_AltPhoneExt & vbcrlf
U_Body = U_Body & "Fax: "& U_Fax & vbcrlf
U_Body = U_Body & "Email: "& U_Email & vbcrlf & vbcrlf
U_Body = U_Body & "Street address: "& U_Address & vbcrlf
U_Body = U_Body & "Tambon: "& U_Tambon & vbcrlf
U_Body = U_Body & "Province: "& U_Province & vbcrlf & vbcrlf
U_Body = U_Body & "Emergency contact details" & vbcrlf
U_Body = U_Body & "Emergency contact person: "& U_EmPrefix & U_EmName & vbcrlf
U_Body = U_Body & "Emergency contact phone: "& U_EmPhone & vbcrlf
'Now lets put the variables and other information we need into the mailing script
Set U_Mail = Server.CreateObject ("CDONTS.NewMail")
U_Mail.From = "
[email protected]"
U_Mail.To = "
[email protected]"
U_Mail.Subject = "Contact details updated "& U_Company
U_Mail.Body = U_Body
U_Mail.Send
set U_Mail=nothing
' *** Edit Operations: declare variables
Dim editAction
Dim abortEdit
Dim editQuery
Dim editCmd
Dim editConnection
Dim editTable
Dim editRedirectUrl
Dim editColumn
Dim recordId
Dim fieldsStr
Dim columnsStr
Dim fields
Dim columns
Dim typeArray
Dim formVal
Dim delim
Dim altVal
Dim emptyVal
Dim i
editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
editAction = editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
abortEdit = false
' query string to execute
editQuery = ""
' *** Update Record: set variables
If (CStr(Request("update")) = "update_form" And CStr(Request("recordId")) <> "") Then
editConnection = conn_STRING
editTable = "CUSTOMERS"
editColumn = "Id"
recordId = "" + Request.Form("recordId") + ""
editRedirectUrl = "/?content=Customer+contact+details+updated+successf ully"
fieldsStr = "login_pass|value|prefix|value|first_name|value|la st_name|value|position|value|phone|value|phone_ext |value|phone_mobile|value|fax|value|email|value|ad dress|value|amphur|value|tambon|value|province|val ue|postalcode|value|alt_phone|value|alt_phone_ext| value|em_prefix|value|em_name|value|em_phone|value |date|value|time|value"
columnsStr = "LoginPass|',none,''|Prefix|',none,''|FirstName|', none,''|LastName|',none,''|Position|',none,''|Work Phone|',none,''|WorkPhoneExt|',none,''|MobilePhone |',none,''|FaxNumber|',none,''|Email|',none,''|Add ress|',none,''|Amphur|',none,''|Tambon|',none,''|P rovince|',none,''|PostalCode|',none,''|Alternative Phone|',none,''|AlternativePhoneExt|',none,''|Emrg cyContactPrefix|',none,''|EmrgcyContactName|',none ,''|EmrgcyContactPhone|',none,''|DateModified|',no ne,NULL|TimeModified|',none,NULL"
' create the fields and columns arrays
fields = Split(fieldsStr, "|")
columns = Split(columnsStr, "|")
' set the form values
For i = LBound(fields) To UBound(fields) Step 2
fields(i+1) = CStr(Request.Form(fields(i)))
Next
' append the query string to the redirect URL
If (editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
editRedirectUrl = editRedirectUrl & "?" & Request.QueryString
Else
editRedirectUrl = editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("update")) <> "" And CStr(Request("recordId")) <> "") Then
' create the sql update statement
editQuery = "update " & editTable & " set "
For i = LBound(fields) To UBound(fields) Step 2
formVal = fields(i+1)
typeArray = Split(columns(i+1),",")
delim = typeArray(0)
If (delim = "none") Then delim = ""
altVal = typeArray(1)
If (altVal = "none") Then altVal = ""
emptyVal = typeArray(2)
If (emptyVal = "none") Then emptyVal = ""
If (formVal = "") Then
formVal = emptyVal
Else
If (altVal <> "") Then
formVal = altVal
ElseIf (delim = "'") Then ' escape quotes
formVal = "'" & Replace(formVal,"'","''") & "'"
Else
formVal = delim + formVal + delim
End If
End If
If (i <> LBound(fields)) Then
editQuery = editQuery & ","
End If
editQuery = editQuery & columns(i) & " = " & formVal
Next
editQuery = editQuery & " where " & editColumn & " = " & recordId
If (Not abortEdit) Then
' execute the update
Set editCmd = Server.CreateObject("ADODB.Command")
editCmd.ActiveConnection = editConnection
editCmd.CommandText = editQuery
editCmd.Execute
editCmd.ActiveConnection.Close
If (editRedirectUrl <> "") Then
Response.Redirect(editRedirectUrl)
End If
End If
End If