I have a form that collects data and passes to an asp page. The ASP page does several things:
1. It assigns form values to fields values
2. It enters the data into a database
3. It accesses a second database to retrive a destinations name from a DestID field value passed from the form.
4. It accesses the database to find the most recent InquiryID submitted by the sender.
5. It sends an email to the site administrator to indicate a new booking
6. It sends an email to the person making the inquiry providing more details.
I would like step 5 to be able to add a link to the email that will open up a page called InquiryDetails.asp that will provide more details about the booking by passing the InquiryID parameter. The InquiryDetails.asp page will be created with FrontPage's Database Results Wizard.
Here is my code:
<%option explicit
dim Title, DestID, FirstName, LastName, OtherNames, PostalCode, Comments, NumberGuests, DestName, _
ContactTime, City, Daytime, Evening, Cell, Fax, State, Country, Ages, StartDate, dState, _
EndDate, NumberDays, Email, Activity, Address1, Address2, objConn, strConn, rs, SQLStmt, _
DestAddress, DestCity, DestState, DestZip, DestCountry, DestTollFree, DestPhone, _
DestFax, DestWebsite, DestEmail, DestLocation, MaxOfInquiryID, InquiryID,RS2, objConn2, _
strConn2, SQLStmt2
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<%
'Assign values from the form data
DestID = Request.Form("DestID")
StartDate = Request.Form("StartDate")
EndDate = Request.Form("EndDate")
NumberGuests = Request.Form("NumberGuests
")
Ages = Trim(Replace(Request.Form(
"Ages"),"'
", "''"))
Activity = Trim(Replace(Request.Form(
"Activity"
),"'", "''"))
NumberDays = Trim(Replace(Request.Form(
"NumberDay
s"),"'", "''"))
Title = Trim(Replace(Request.Form(
"Title"),"
'", "''"))
FirstName = Trim(Replace(Request.Form(
"FirstName
"),"'", "''"))
LastName = Trim(Replace(Request.Form(
"LastName"
),"'", "''"))
OtherNames = Trim(Replace(Request.Form(
"OtherName
s"),"'", "''"))
Address1 = Trim(Replace(Request.Form(
"Address1"
),"'", "''"))
Address2 = Trim(Replace(Request.Form(
"Address2"
),"'", "''"))
City = Trim(Replace(Request.Form(
"City"),"'
", "''"))
State = Trim(Replace(Request.Form(
"State"),"
'", "''"))
Country = Trim(Replace(Request.Form(
"Country")
,"'", "''"))
PostalCode = Trim(Replace(Request.Form(
"PostalCod
e"),"'", "''"))
Daytime = Trim(Replace(Request.Form(
"Daytime")
,"'", "''"))
Evening = Trim(Replace(Request.Form(
"Evening")
,"'", "''"))
Cell = Trim(Replace(Request.Form(
"Cell"),"'
", "''"))
Fax = Trim(Replace(Request.Form(
"Fax"),"'"
, "''"))
Email = Trim(Replace(Request.Form(
"Email"),"
'", "''"))
ContactTime = Trim(Replace(Request.Form(
"ContactTi
me"),"'", "''"))
Comments = Trim(Replace(Request.Form(
"Comments"
),"'", "''"))
'Get the value of the Destination Name to match the DestID
Set objConn = Server.CreateObject("ADODB
.Connectio
n")
objConn.ConnectionString = "Provider=Microsoft.Jet.OL
EDB.4.0;Da
ta Source=" & _
Server.MapPath ("../fpdb/Destinations.mdb
") & ";"
objConn.Open
SQLStmt = "SELECT * FROM qDestLocations WHERE DestID = " & DestID
Set RS = ObjConn.execute(SQLStmt)
If err.number>0 then
response.write "VBScript Errors Occurred:" & "<p>"
response.write "Error Number=" & err.number & "<p>"
response.write "Error Descr.=" & err.description & "<p>"
response.write "Help Context=" & err.helpcontext & "<P>"
response.write "Help Path=" & err.helppath & "<P>"
response.write "Native Error=" & err.nativeerror & "<P>"
response.write "Source=" & err.source & "<P>"
response.write "SQLState=" & err.sqlstate & "<P>"
end if
If objConn.errors.count>0 then
response.write "Database Errors Occurred" & "<P>"
response.write SQLStmt & "<P>"
for counter=0 to objConn.errors.count
response.write "Error #" & objConn.errors(counter).nu
mber & "<P>"
response.write "Error desc. -> " & objConn.errors(counter).de
scription & "<P>"
next
else
Do While Not RS.EOF
' This assigns DestLocation to a variable
DestName = RS("DestName")
DestLocation = RS("DestLocation")
DestAddress = RS("Address")
DestCity = RS("City")
DestState = RS("State")
DestZip = RS("ZipCode")
DestCountry = RS("Country")
DestTollFree = RS("TollFree")
DestPhone = RS("Phone")
DestFax = RS("Fax")
DestWebsite = RS("Website")
DestEmail = RS("Email")
RS.MoveNext
Loop
end if
objConn.close
set objConn=nothing
set rs=nothing
%>
<%
'enter the form data into the database
Set objConn = Server.CreateObject("ADODB
.Connectio
n")
objConn.ConnectionString = "Provider=Microsoft.Jet.OL
EDB.4.0;Da
ta Source=" & _
Server.MapPath ("../fpdb/Booking.mdb") & ";"
objConn.Open
SQLStmt = "INSERT INTO tBookings(DestID, StartDate, EndDate, NumberGuests, Ages, Activity, NumberDays, Title, FirstName, LastName, OtherNames, Address1, Address2, City, State, Country, PostalCode, Daytime, Evening, Cell ,Fax, Email, ContactTime, Comments)"
SQLStmt = SQLStmt & " values ("
SQLStmt = SQLStmt & "'" & DestID & "', "
SQLStmt = SQLStmt & "'" & StartDate & "', "
SQLStmt = SQLStmt & "'" & EndDate & "', "
SQLStmt = SQLStmt & "'" & NumberGuests & "', "
SQLStmt = SQLStmt & "'" & Ages & "', "
SQLStmt = SQLStmt & "'" & Activity & "', "
SQLStmt = SQLStmt & "'" & NumberDays & "', "
SQLStmt = SQLStmt & "'" & Title & "', "
SQLStmt = SQLStmt & "'" & FirstName & "', "
SQLStmt = SQLStmt & "'" & LastName & "', "
SQLStmt = SQLStmt & "'" & OtherNames & "', "
SQLStmt = SQLStmt & "'" & Address1 & "', "
SQLStmt = SQLStmt & "'" & Address2 & "', "
SQLStmt = SQLStmt & "'" & City & "', "
SQLStmt = SQLStmt & "'" & State & "', "
SQLStmt = SQLStmt & "'" & Country & "', "
SQLStmt = SQLStmt & "'" & PostalCode & "', "
SQLStmt = SQLStmt & "'" & Daytime & "', "
SQLStmt = SQLStmt & "'" & Evening & "', "
SQLStmt = SQLStmt & "'" & Cell & "', "
SQLStmt = SQLStmt & "'" & Fax & "', "
SQLStmt = SQLStmt & "'" & Email & "', "
SQLStmt = SQLStmt & "'" & ContactTime & "', "
SQLStmt = SQLStmt & "'" & Comments & "'"
SQLStmt = SQLStmt & ")"
Set RS = ObjConn.execute(SQLStmt)
If err.number>0 then
response.write "VBScript Errors Occurred:" & "<p>"
response.write "Error Number=" & err.number & "<p>"
response.write "Error Descr.=" & err.description & "<p>"
response.write "Help Context=" & err.helpcontext & "<P>"
response.write "Help Path=" & err.helppath & "<P>"
response.write "Native Error=" & err.nativeerror & "<P>"
response.write "Source=" & err.source & "<P>"
response.write "SQLState=" & err.sqlstate & "<P>"
end if
If objConn.errors.count>0 then
response.write "Database Errors Occurred" & "<P>"
response.write SQLStmt & "<P>"
for counter=0 to objConn.errors.count
response.write "Error #" & objConn.errors(counter).nu
mber & "<P>"
response.write "Error desc. -> " & objConn.errors(counter).de
scription & "<P>"
next
else
response.write "<font face='arial'<b>"
response.write "The booking has been recorded. You will receive an email shortly that will give you additional details about your upcoming activity. MountainNature.com works with only the very best activity suppliers. Your satisfaction is our number one concern. If you are in any unsatisfied with our partner suppliers, please feel free to contact us with any questions you may have.</b><P>"
end if
objConn.close
set objConn=nothing
set rs=nothing
%>
<%
'Get the most recent InquiryID for this person
Set objConn2 = Server.CreateObject("ADODB
.Connectio
n")
objConn2.ConnectionString = "Provider=Microsoft.Jet.OL
EDB.4.0;Da
ta Source=" & _
Server.MapPath ("../fpdb/Booking.mdb") & ";"
objConn2.Open
SQLStmt2 = "SELECT Max(InquiryID) AS MaxOfInquiryID FROM tBookings Having (FirstName = FirstName) AND (LastName = LastName) AND (DestID = DestID)"
Set RS2 = ObjConn2.execute(SQLStmt2)
Do While Not RS2.EOF
InquiryID = RS2("MaxOfInquiryID")
RS2.MoveNext
Loop
objConn2.close
set objConn2=nothing
set rs2=nothing
'Send a message to the Site Administrator
Dim MyMail
Set MyMail = CreateObject("CDONTS.NewMa
il")
MyMail.From= Request.Form("Email")
MyMail.To= "info@mountainnature.com"
MyMail.Subject="New Tour Booking at MountainNature.com"
MyMail.Body = "There is a new booking at Mountainnature.com. " _
& chr(13) & chr(13) & "Destination: " & DestLocation & ", " & dState & chr(13) & "Activity: " _
& Activity & chr(13) & "Name: " & FirstName _
& " " & LastName & chr(13) & "Other Participants: " _
& OtherNames & chr(13) & "Address Line 1: " _
& Address1 & chr(13) & "Address Line 2: " & Address2 _
& chr(13) & "City: " & City & chr(13) & "Province/State: " & State _
& chr(13) & "Country: " & Country & chr(13) & "Postal/Zip Code: " _
& PostalCode & chr(13) & "Daytime Phone: " & Daytime & chr(13) _
& "Evening Phone: " & Evening & chr(13) & "Fax: " & Fax & chr(13) _
& "Cell Phone: " & Cell & chr(13) & chr(13) & "Details: " & Comments
MyMail.Send
set MyMail=nothing
%>
<%
'Send a message to the person making the inquiry
Dim MyMail2
Set MyMail2 = CreateObject("CDONTS.NewMa
il")
MyMail2.From= "info@mountainnature.com"
MyMail2.To= request.form("Email")
MyMail2.Subject="Thank you for your tour inquiry"
MyMail2.Body = "Thank you so much for your interest in taking part in a " _
& Request.Form("Activity") & " in " & DestLocation & ". Here is a summary of what you requested:" _
& chr(13) & chr(13) & "Destination: " & DestLocation & chr(13) & "Activity: " _
& Request.Form("Activity") & chr(13) & "Name: " & Request.form("FirstName") _
& " " & Request.Form("LastName") & chr(13) & "Other Participants: " _
& Request.Form("OtherNames")
& chr(13) & "Address Line 1: " _
& Request.Form("Address1") & chr(13) & "Address Line 2: " & Request.Form("Address2") _
& chr(13) & "City: " & Request.Form("City") & chr(13) & "Province/State: " & Request.form("State") _
& chr(13) & "Country: " & Request.Form("Country") & chr(13) & "Postal/Zip Code: " _
& Request.Form("PostalCode")
& chr(13) & "Daytime Phone: " & Request.Form("Daytime") & chr(13) _
& "Evening Phone: " & Request.Form("Evening") & chr(13) & "Fax: " & Request.Form("Fax") & chr(13) _
& "Cell Phone: " & Request.Form("Cell") & chr(13) & chr(13) & "Details: " & Request.Form("Comments") _
& chr(13) & chr(13) & "For more information on " & DestName & ", please use the following contact information" _
& chr(13) & chr(13) & DestName & chr(13) & DestAddress _
& chr(13) & DestState & chr(13) & DestZip & chr(13) _
& DestCountry & chr(13) & chr(13) & "Toll Free Number: " & DestTollFree _
& chr(13) & "Telephone: " & DestPhone & chr(13) & "Fax: " & DestFax _
& chr(13) & "Email: " & DestEmail & chr(13) & "Website: " & DestWebsite
MyMail2.Send
set MyMail2=nothing
response.end
%>
</body>
</html>
Start Free Trial