%@ Language=VBScript %> <% Option Explicit %> <% Const ORGANISER_EMAIL = "enquiries@spencersmenu.co.uk" 'Const ORGANISER_EMAIL = "Dave.Fourie@SpencersMenu.com" 'Const ORGANISER_EMAIL = "graeme@active-answer.co.uk" Const ORGANISER_COMPANY = "Spencers Direct Website Enquiry" 'Const MAILHOST = "mail.spencersmenu.co.uk" Const MAILHOST = "pop.spencersmenu.co.uk" Const FM_ENTER = 0 ' Enter the form Const FM_CHECK = 1 ' Checking contents Const FM_EMAIL_SENT = 2 ' Email has been sent Const FM_EMAIL_ERROR = 3 ' Error Sending Email Const FM_FORM_ERROR = 4 ' Error in the form ' Check on the form mode Dim FMode ' Form Mode Dim NxMode ' Next Form Mode Dim Name ' Name on form Dim Email ' Email on form Dim Tel ' Telephone on form Dim Addr ' Address on the form Dim PostCode ' Postcode on the form Dim Enquiry ' Company on the form Dim eMsg ' Error Message Dim dbConn1, rs1 ' Database Access Data ' ********************************** ' Checks for a valid email address ' ' Returns: true email address is good ' false email address is bad ' ********************************** Function checkEmail(emStr) Dim r1, r2 ' Regular expression objects Set r1 = new RegExp r1.Pattern = "(@.*@)|(\.\.)|(@\.)|(^\.)" Set r2 = new RegExp r2.Pattern = "^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$" If Not(r1.Test(emStr)) and r2.Test(emStr) Then checkEmail = true Else checkEmail = false End If End Function ' ******************************** ' Read the form details ' ******************************** Sub ReadForm() Name = Request.Form("txtName") Addr = Request.Form("txtAddress") Tel = Request.Form("txtTel") Email = Request.Form("txtEmail") Enquiry = Request.Form("txtEnquiry") PostCode = Request.Form("txtPostCode") End Sub ' ************************************************************ ' Attempts to store the client data in a cookie dictionary ' ************************************************************ Sub fetchClientInfo ' ******************************* ' Check if the cookies exist ' ******************************* If Request.Cookies("Spencers").HasKeys() = True Then Name = Request.Cookies("Spencers")("Name") Addr = Request.Cookies("Spencers")("Addr") Tel = Request.Cookies("Spencers")("Tel") Email = Request.Cookies("Spencers")("Email") PostCode = Request.Cookies("Spencers")("PostCode") End If End Sub ' ************************************************************ ' Attempts to store the client data in a cookie dictionary ' ************************************************************ Sub persistClientInfo() Response.Cookies("Spencers")("Name") = Name Response.Cookies("Spencers")("Addr") = Addr Response.Cookies("Spencers")("Tel") = Tel Response.Cookies("Spencers")("Email") = Email Response.Cookies("Spencers")("PostCode") = PostCode Response.Cookies("Spencers").Expires = DateAdd("m", 12, Now()) End Sub ' ******************************* ' check the values on the form ' ******************************* Function checkForm() eMsg = "" If Len(Name) = 0 Then emsg = emsg & wrErr("Please enter your name.") End If If Len(Enquiry) = 0 Then emsg = emsg & wrErr("Please enter some enquiry details.") End If If checkEmail(Email) = False Then emsg = emsg & wrErr("Please enter a valid email address.") End If If Len(Emsg) > 0 then checkForm = False Else checkForm = True End If End Function ' ***************************************** ' Format the error code ' ***************************************** Function wrErr(Str) wrErr = "
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||