[thelist] Form Handling Agony

alan herrell - the head lemur headlemur at lemurzone.com
Fri Nov 4 10:37:44 CST 2005


What I *don't know about .asp* would fill the Grand Canyon from top to 
bottom.

I have a form handler that I have been using for years, that would take 
the information from a request form, and using CDONTS, would
send email to the receipents.

According to my host, CDONTS still works.They have recently upgraded.
CDO.Newmail is the new component I guess.

The email used to  show up like this:

Email: sally at larry.com
Make:AUDI
Year: 1978
Model:A8 cab
Bodystyle: 4-Door
Fueltype:Diesel
Transmission: 3-Speed
STDPart_Requested:wheel(,)bracker for turbo bypass mod
Addinfo:
Vin:
Name: pu
Phone:333333333333333
Address:
City:
State: -Select-
Zip:
Country:


*It broke. and I don't know how to fix it.*

What it does now is to combine two lines together before putting the 
next line in.


Email: sally at larry.comMake:AUDI
Year: 1978Model:A8 cab
Bodystyle: 4-DoorFueltype:Diesel
Transmission: 3-Speed STDPart_Requested:wheel(,)bracker for turbo bypass 
mod
Addinfo:
Vin:
Name: puPhone:333333333333333
Address:
City:
State: -Select-Zip:Country:

This is the code I am using:
--------------------------------------------------------------------
<%@language = "VBscript"%>
<%
Dim strError
Response.Buffer = True
If ScriptEngineMajorVersion < 2 Then
ReportError "Host system needs scripting engine upgrade to use this script"
End If
Set objFM = CreateObject("Scripting.Dictionary")
If IsObject(objFM) = False Then
ReportError "Host system lacks component(s) required by this script"
End If
Set objMailx = CreateObject("CDO.Message")
If IsObject(objMailx) = False Then
ReportError "Host system lacks component(s) required by this script"
End If
Set objMailx = Nothing
%>

<%'variables you can set start here%>
<%
strRcpt = "B and B Hotline Members<info at bnbhotline.com>" 'Put the 
address you want the form sent to here
strBCC =  "headlemur at lemurzone.com"
strFromVar = "Email" 'If you want a reply-to email address to be taken 
from the form
' put the name of the input item here.
strDefFrom = "memberlist at bnbhotline.com" 'Put a default, even fake, 
 >From address here
strDefSubject = "B and B Hotline Part Request" 'Put the subject of the 
letter here. If an input item called
' subject exists in the form, its value will be used instead.
strRedirect = "http://bnbhotline.com/thanks.htm" 'Url to redirect to 
after a successful form submission.
' If an input item called redirect exists in the form, its value will be 
used instead.
%>
<%' variables you can set end here%>

<%
ParseForm
CheckForm
If Len(strError) > 0 Then
ReportError strError
End If
strOutX = SeqForm
If Len(strOutX) < 1 Then
strOutX = FormToString
End If
If Len(strOutX) < 1 Then
ReportError "Submitted form is empty"
End If
strSubject = strDefSubject
If objFM.Exists("subject") Then
strSubject = objFM.Item("subject")
End If
strFrom = strDefFrom
If Len(strFromVar) > 0 Then
If objFM.Exists(strFromVar) Then strFrom = objFM.Item(strFromVar) End If
End If
SendMail strFrom,strRcpt,strBCC,strSubject,strOutX
If Len(strRedirect) > 0 Then
Response.redirect(strRedirect)
Response.End
End If
If objFM.Exists("redirect") = True Then
If Len(objFM.Item("redirect")) > 0 Then
Response.redirect(objFM.Item("redirect"))
Response.End
End If
End If
%>

<!--*******SUCCESSFUL SUBMISSION RESPONSE - START*******-->
<!--ADD YOUR OWN HTML TOP SECTION STARTING HERE-->
<h1>Form Sent!</h1>
Your request has been received and will be processed shortly.
<!--ADD YOUR OWN HTML TOP SECTION UP TO HERE-->
<!--*******SUCCESSFUL SUBMISSION RESPONSE - END********-->

<%
Credit
Response.End
%>
<%
Function IsValidEmail(Email)
Dim Temp,Temp2
strNotValid = "<br>Email address not valid"
strTooLong = "<br>Email address too long"
If Len(Email) > 50 Then '[5000 not necessary anymore]
ReportError strTooLong
End If
Email = LCase(Email)
Temp = Split(Email,"@",2,1)
If UBound(Temp) < 1 Then
ReportError strNotValid
End If
Temp2 = Split(Temp(1),".",-1,1)
If UBound(Temp2) < 1 Then
ReportError strNotValid
End If
End Function
%>
<%
Function SendMail(From,Rcpt,Blind,Subject,Body)
Trim(From)
Trim(Rcpt)
If Len(From) < 1 Then
ReportError strError & "<br>No Reply-to address (From) for this letter"
End If
If Len(Rcpt) < 1 Then
ReportError strError & "<br>No recipient for this letter"
End If
'IsValidEmail Rcpt '[commented out as not necessary as it's hardcoded]
IsValidEmail From
Set objMailer = CreateObject("CDO.Message")
objMailer.From = From
objMailer.To = Rcpt
objMailer.BCC = Blind
objMailer.Subject = Subject
objMailer.Body = Body
objMailer.Send
Set objMailer = Nothing
End Function
%>
<%
Function CheckForm()
Dim Temp,strTmp,strForce
strInputReq = "<br>Input required for "
If objFM.Exists("require") = False Then
Exit Function
ElseIf isEmpty(objFM.Item("require")) Then
Exit Function
End If
strForce = objFM.Item("require")
Temp = Split(strForce,",",-1,1)
For Each strTmp in Temp
If objFM.Exists(strTmp) = False Then
strError = strError & strInputReq & strTmp
ElseIf Len(objFM.Item(strTmp)) < 1 Then
strError = strError & strInputReq & strTmp
End If
Next
End Function
%>
<%
Function ParseForm()
For Each Item in Request.Form
If objFM.Exists(Item) Then
objFM.Item(Item) = objFM.Item(Item) & "," & Request.QueryString(Item)
Else
objFM.Add Item,Request.Form(Item)
End If
Next
For Each Item in Request.QueryString
If objFM.Exists(Item) Then
objFM.Item(Item) = objFM.Item(Item) & "," & Request.QueryString(Item)
Else
objFM.Add Item,Request.QueryString(Item)
End If
Next
End Function
%>
<%
Function SeqForm()
Dim Temp,strTmp,strOrder,strOut
If objFM.Exists("order") = False Then
Exit Function
ElseIf isEmpty(objFM.Item("order")) Then
Exit Function
End If
strOrder = objFM.Item("order")
Temp = Split(strOrder,",",-1,1)
For Each strTmp in Temp
If objFM.Exists(strTmp) Then
strOut = strOut & strTmp & ": " & objFM.Item(strTmp) & Chr(10)
End If
Next
SeqForm = strOut
End Function
%>
<%
Function FormToString()
Dim strOut
strKeys = objFM.Keys
strValues = objFM.Items
For intCnt = 0 To objFM.Count -1
strOut = strOut & strKeys(intCnt) & ": " & strValues(intCnt) & Chr(10)
Next
FormToString = strOut
End Function
%>
<%
Function ReportError(strMess)
If Len(strMess) < 1 Then
strMess = strError
End If
strErr = "The following error(s) happened: <br>" & strMess
Response.Clear
%>

<!--*******ERRONEOUS SUBMISSION RESPONSE - START*******-->
<!--ADD YOUR OWN HTML TOP SECTION STARTING HERE-->
<h1>Error!</h1>

<!--ADD YOUR OWN HTML TOP SECTION UP TO HERE-->

<%'Error messages will be output here, between your html%>
<%
Response.Write(strErr)
%>

<!--ADD YOUR OWN HTML BOTTOM SECTION STARTING HERE-->
<p>
<b>Click on you browser's <i>Back</i> button to correct any mistakes in 
your input</b>
</p>
<!--ADD YOUR OWN HTML BOTTOM SECTION UP TO HERE-->
<!--******ERRONEOUS SUBMISSION RESPONSE - END*******-->
<%
Response.End
End Function
%>

<%Function Credit%>
<!--START OF CREDIT - DO NOT CHANGE OR REMOVE ANYTHING BELOW THIS LINE-->
<p align=center>
test message
</font>
</p>
<!--END OF CREDIT-->
<%End Function%>

any help would be  appreciated!




-- 
alan herrell
the head lemur

raving lunacy - Oxymorons for the 21st Century
http://theheadlemur.typepad.com/ravinglunacy/






More information about the thelist mailing list