<%option explicit%> <%DIM ErrorMsg,xFirst_Name,xLast_Name,xsocial_security,xaddress,xcity,xstate,xzip_code,xtelephone,xemail%> <% const numFields = 9 dim errorArray() redim preserve errorArray(numFields) if request.form("isSubmitted") = "yes" then xfirst_name = Trim(Replace(Request.Form("xfirst_name"),"'","")) xlast_name = Trim(Replace(Request.Form("xlast_name"),"'","")) xsocial_security = Trim(Replace(Request.Form("xsocial_security"),"'","")) xaddress = Trim(Replace(Request.Form("xaddress"),"'","")) xcity = Trim(Replace(Request.Form("xcity"),"'","")) xstate = Trim(Replace(Request.Form("xstate"),"'","")) xzip_code = Trim(Replace(Request.Form("xzip_code"),"'","")) xtelephone = Trim(Replace(Request.Form("xtelephone"),"'","")) xemail = Trim(Replace(Request.Form("xemail"),"'","")) ErrorMsg = "" dim re set re = New RegExp 'First Name re.Pattern = "^[^0-9\/><\.,\\!\^\$\*\+\?@#%&\(\);:\[\]\{\}=""']+$" re.Global = True re.IgnoreCase = True errorArray(0) = re.Test(xfirst_name) if errorArray(0) then errorArray(0)=False else errorArray(0) = True ErrorMsg = "First Name
" end if 'Last Name if Len(xlast_name) = 0 then errorArray(1) = True ErrorMsg = ErrorMsg & "Last Name
" end if 'Zip Code re.Pattern = "^\d{5}(-\d{4})?$" errorArray(6) = re.Test(xzip_code) if errorArray(6) then errorArray(6) = False else errorArray(6) = True ErrorMsg = ErrorMsg & "Zip Code
" end if 'Telephone re.Pattern = "^\d{3}-\d{3}-\d{4}$" errorArray(7) = re.Test(xtelephone) if errorArray(7) then errorArray(7) = False else errorArray(7) = True ErrorMsg = ErrorMsg & "Telephone Number
" end if 'Email re.Pattern = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" errorArray(8) = re.Test(xemail) if errorArray(8) then errorArray(8) = False else errorArray(8) = True ErrorMsg = ErrorMsg & "Email Address
" end if end if %> TexasWebDevelopers--A Dallas Texas Web Design and Development Company.
<% if ErrorMsg <> "" then %> <%= ErrorMsg %> <%end if%>
<% if errorArray(0) = True then %> <% end if %>First Name: <% if errorArray(0) = True then %> <% end if %>
<% if errorArray(1) = True then %> <% end if %>Last Name: <% if errorArray(1) = True then %> <% end if %>
Social Security:
Address:
City:
State:
<% if errorArray(6) = True then %> <% end if %>Zip Code: <% if errorArray(6) = True then %> <% end if %> format: xxxxx
<% if errorArray(7) = True then %> <% end if %>Telephone No.: <% if errorArray(7) = True then %> <% end if %> format xxx-xxx-xxxx
<% if errorArray(8) = True then %> <% end if %>Email Address: <% if errorArray(8) = True then %> <% end if %>
<%if request.form("isSubmitted") = "yes" then%> <% DIM all,i all=False For i=0 to 8 all=all OR CBOOL(errorArray(i)) Next If Not all Then xfirst_name = Trim(Replace(Request.Form("xfirst_name"),"'","")) xlast_name = Trim(Replace(Request.Form("xlast_name"),"'","")) xsocial_security = Trim(Replace(Request.Form("xsocial_security"),"'","")) xaddress = Trim(Replace(Request.Form("xaddress"),"'","")) xcity = Trim(Replace(Request.Form("xcity"),"'","")) xstate = Trim(Replace(Request.Form("xstate"),"'","")) xzip_code = Trim(Replace(Request.Form("xzip_code"),"'","")) xtelephone = Trim(Replace(Request.Form("xtelephone"),"'","")) xemail = Trim(Replace(Request.Form("xemail"),"'",""))%> <% 'This sends and email to you with a link to your database results form Dim str str = "Form Request from TWD Validation Script" & vbCrLf & vbCrLf str = str & "Contact information From: " & vbCrLf str = str & "Name: " & Request.Form("xfirst_name") & " " & Request.Form("xlast_name") & vbCrLf str = str & "Social Security #: " & Request.Form("xsocial_security") & vbCrLf str = str & "Address: " & Request.Form("xaddress") & vbCrLf str = str & Request.Form("xcity") & ", " & Request.Form("xstate") &" " & Request.Form("xzip_code") & vbCrLf str = str & "Phone: " & Request.Form("xtelephone")& vbCrLf str = str & "mailto:" & Request.Form("xeMail") & vbCrLf & vbCrLf str = str & "Link to my site's Database:" & vbCrLf str = str & "http://www.texaswebdevelopers.com/admin/admin_validation/default.asp" & vbCrLf str = str & "Login=admin and Password=admin" & vbCrLf & vbCrLf str = str & "THIS IS THE SAMPLE EMAIL THAT WOULD GO TO YOU" Dim myMail Set myMail = Server.CreateObject("SMTPsvg.Mailer") myMail.RemoteHost = "mail.commercestreet.com" myMail.FromAddress = Request.Form("xeMail") myMail.AddRecipient Request.Form("xfirst_name"), Request.Form("xeMail") myMail.Subject = "Form Validation Response" myMail.BodyText = str myMail.SendMail Set myMail = Nothing %> <% 'This sends an eMail to the user who filled out the form Dim str2 str2 = "Thank you for testing the validation form at TexasWebDevelopers.com" & vbCrLf & vbCrLf str2 = str2 & "Here is the updated contact information you provided:" & vbCrLf & vbCrLf str2 = str2 & "Name: " & Request.Form("xfirst_name") & " " & Request.Form("xlast_name") & vbCrLf str2 = str2 & "Social Security #: " & Request.Form("xsocial_security") & vbCrLf str2 = str2 & "Address: " & Request.Form("xaddress") & vbCrLf str2 = str2 & Request.Form("xcity") & ", " & Request.Form("xstate") &" " & Request.Form("xzip_code") & vbCrLf str2 = str2 & "Phone: " & Request.Form("xtelephone")& vbCrLf str2 = str2 & "mailto:" & Request.Form("xeMail") & vbCrLf & vbCrLf str2 = str2 & "THIS IS THE SAMPLE EMAIL THAT WOULD GO TO THE USER" & vbCrLf & vbCrLf Dim myMail2 Set myMail2 = Server.CreateObject("SMTPsvg.Mailer") myMail2.RemoteHost = "mail.commercestreet.com" myMail2.FromAddress = Request.Form("xeMail") myMail2.AddRecipient Request.Form("xfirst_name"), Request.Form("xeMail") myMail2.Subject = "Thank you" myMail2.BodyText = str2 myMail2.SendMail Set myMail2 = Nothing %> <% ' this is where the information finally gets submitted to the database DIM Conn,strConn,SQLstmt,RS set Conn = server.createobject("adodb.connection") strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/database/validation.mdb") Conn.open strConn SQLstmt = "INSERT INTO users (xfirst_name,xlast_name,xsocial_security,xaddress,xcity,xstate,xzip_code,xtelephone,xemail)" SQLstmt = SQLstmt & " VALUES (" SQLstmt = SQLstmt & "'" & xfirst_name & "'," SQLstmt = SQLstmt & "'" & xlast_name & "'," SQLstmt = SQLstmt & "'" & xsocial_security & "'," SQLstmt = SQLstmt & "'" & xaddress & "'," SQLstmt = SQLstmt & "'" & xcity & "'," SQLstmt = SQLstmt & "'" & xstate & "'," SQLstmt = SQLstmt & "'" & xzip_code & "'," SQLstmt = SQLstmt & "'" & xtelephone & "'," SQLstmt = SQLstmt & "'" & xeMail & "'" SQLstmt = SQLstmt & ")" Set RS = conn.execute(SQLstmt) If err.number>0 then response.write "VBScript Errors Occured:" & "

" response.write "Error Number=" & err.number & "

" response.write "Error Descr.=" & err.description & "

" response.write "Help Context=" & err.helpcontext & "

" response.write "Help Path=" & err.helppath & "

" response.write "Native Error=" & err.nativeerror & "

" response.write "Source=" & err.source & "

" response.write "SQLState=" & err.sqlstate & "

" end if IF conn.errors.count> 0 then response.write "Database Errors Occured" & "

" response.write SQLstmt & "

" for counter= 0 to conn.errors.count response.write "Error #" & conn.errors(counter).number & "

" response.write "Error desc. -> " & conn.errors(counter).description & "

" next else Response.Redirect("formvalidredirect.asp?updated=true") end if end if end if %>