Read Chapter 10 of Dreamweaver MX: The missing manual
The way I do forms at the library – 2 pages.
1 page – form
1 page – confirmation and processing
Using ASP/SQL
We have JMAIL on campus to process forms
I use POST – as I am sending a bunch of information at any given time.
I validate the forms to require certain fields to be completed. I use the Dreamweaver helpers to do this.
http://library.wcu.edu/libraryservices/requestFAD.asp
Here’s the form beginning:
<form action="requestfadconf.asp" method="post" name="form1" onSubmit="MM_validateForm('name','','R','email','','RisEmail','citation','','R');return document.MM_returnValue">
Action – where the form will be process
Method – use post
Name – call it something that works for you
The rest – added by dreamweaver when I used behaviors - validation
Then insert and format all the fields
Then submit
Then end form
<INPUT TYPE="SUBMIT" VALUE="Submit Request">
</form>
http://library.wcu.edu/libraryservices/requestFADconf.asp
Here’s the confirmation code I’m using:
This piece makes sure that robot/spammer cannot send a fake email through by tripping the script. Saves lots of annoying empty email. Says, if email on the request form is blank, then redirect it to the confirmation page, where you can’t have blank email. It squelches the process.
<%
IF request.form("email") = "" THEN response.redirect("requestFAD.asp")%>
Email – the field on the data collection form that can’t be blank
RequestFAD.asp – the name of the data collection form
Next, you define the fields that are coming from your request form.
<%
dim sender, subject, smtpServer, smtpPort, strname, strphone, stremail, strdepartment, strcitation, receiver, sendername
strname = Request.Form("name")
strphone = Request.Form("phone")
stremail = Request.Form("email")
strdepartment = Request.Form("department")
strcitation = Request.Form("citation")
Then you list the fields you want to receive back in the email you receive that contains the form info. You format them too.
body = "Name : " & Request.Form("name") & vbCrLf & vbCrLf
body = body & "Phone : " & Request.Form("phone") & vbCrLf & vbCrLf
body = body & "Email : " & Request.Form("email") & vbCrLf & vbCrLf
body = body & "Department : " & Request.Form("department") & vbCrLf & vbCrLf
body = body & "Citation(s) : " & Request.Form("citation") & vbCrLf & vbCrLf
The first part, after the body= is what you want included in your email for text to help you identify the data that is coming from the form.
The second part is the field you identified above.
vbCrLf – virtual basic carriage return line feed – makes a line break. Use two if you want a blank line between fields.
Then you put your email information.
' Put your SMTP Mail server here. If you do not know, ask your network administrator
smtpServer = "email.wcu.edu"
smtpPort = 25
receiver = "articledelivery@email.wcu.edu"
sender = "articledelivery@email.wcu.edu"
sendername = "FAD Request"
subject = "FAD Request"
customize these setting to match your mail server and the to/from email you want
' ---
Set JMail = Server.CreateObject ("JMail.SMTPMail")
JMail.ServerAddress = smtpServer & ":" & smtpPort
JMail.Sender = sender
JMail.SenderName = sendername
JMail.Subject = subject
JMail.AddRecipient receiver
JMail.ContentType = "text/plain"
JMail.ISOEncodeHeaders = false
JMail.ContentTransferEncoding = "8bit"
JMail.Body = body
' 1 - highest priority (Urgent) ' 3 - normal ' 5 - lowest
JMail.Priority = 3
' Actually send mail
JMail.Execute
set JMail = nothing
Then you create the response message that shows on the confirmation page.
Response.write "<h2>Your request has been successfully submitted.</h2>"
%>
We have a two part action for this particular form. The part above sends the info to articledelivery. The part below is a receipt for the requestor. It’s pretty much the same info, but it sends to the email address they submit.
<%
dim sender2, subject2, smtpServer2, smtpPort2, strname2, strphone2, stremail2, strdepartment2, strcitation2, receiver2, sendername2
strname2 = Request.Form("name")
strphone2 = Request.Form("phone")
stremail2 = Request.Form("email")
strdepartment2 = Request.Form("department")
strcitation2 = Request.Form("citation")
body = "Name : " & Request.Form("name") & vbCrLf & vbCrLf
body = body & "Phone : " & Request.Form("phone") & vbCrLf & vbCrLf
body = body & "Email : " & Request.Form("email") & vbCrLf & vbCrLf
body = body & "Department : " & Request.Form("department") & vbCrLf & vbCrLf
body = body & "Citation(s) : " & Request.Form("citation") & vbCrLf & vbCrLf
' Put your SMTP Mail server here. If you do not know, ask your network administrator
smtpServer2 = "email.wcu.edu"
smtpPort2 = 25
receiver2 = Request.Form("email")
sender2 = "articledelivery@email.wcu.edu"
sendername2 = "FAD Request"
subject2 = "FAD Request"
' ---
Set JMail = Server.CreateObject ("JMail.SMTPMail")
JMail.ServerAddress = smtpServer2 & ":" & smtpPort2
JMail.Sender = sender2
JMail.SenderName = sendername2
JMail.Subject = subject2
JMail.AddRecipient receiver2
JMail.ContentType = "text/plain"
JMail.ISOEncodeHeaders = false
JMail.ContentTransferEncoding = "8bit"
JMail.Body = body
' 1 - highest priority (Urgent) ' 3 - normal ' 5 - lowest
JMail.Priority = 3
' Actually send mail
JMail.Execute
set JMail = nothing
%>
Hunter Library | Library Insider | Last updated: 7/18/06 Melissa Young