<%@ 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 = "
  • " & Str & "
  • " & vbCrLf End Function ' ****************************************************** ' Send the Message notification email ' ****************************************************** Function sendEmail() Dim StrMessHdr ' Header for the message string Dim StrMessFtr ' Header for the message string Dim StrMess ' Message string Dim Mailer ' Mailer Object ' Create the mailer object Set Mailer = Server.CreateObject("SMTPsvg.Mailer") ' Set the Mail From Information Mailer.FromName = Name Mailer.FromAddress = Email Mailer.RemoteHost = MAILHOST ' ******************************** ' Set up the recipient address '' ******************************** Mailer.AddRecipient ORGANISER_COMPANY, ORGANISER_EMAIL Mailer.Subject = "Spencerdirect Website Enquiry Notice" StrMessHdr = VbCrLf & "---------------- Spencerdirect Website Enquiry Notice ------------------" & VbCrlf & VbCrlf StrMess = "Date: " & FormatDateTime(Now(), 1) & vbCrLf StrMess = StrMess & "Name: " & Name & vbCrLf StrMess = StrMess & "Address : " & Addr & vbCrLf StrMess = StrMess & "Postcode : " & PostCode & vbCrLf StrMess = StrMess & "Telephone: " & Tel & vbCrLf StrMess = StrMess & "Email: " & Email & vbCrLf StrMess = StrMess & "Enquiry: " & vbCrLf StrMess = StrMess & Enquiry & vbCrLf & vbCrLf StrMessFtr = VbCrLf & "-------------------------------- End -------------------------------------" & VbCrlf ' Fill in the body text from the form Mailer.BodyText = StrMessHdr & StrMess & StrMessFtr if not Mailer.SendMail then sendEmail = FM_EMAIL_ERROR else sendEmail = FM_EMAIL_SENT end if set Mailer = nothing End Function ' **************************************** ' Build the Quick Link DropDown Options ' **************************************** Sub BuildLinkOption Dim rso Dim cmdt, NItems dim ccatid cmdt = "SELECT Category, CatID FROM Category ORDER BY DisplayOrder" set rso = dbConn1.Execute(cmdt, NItems) While rso.Eof = false ccatid = rso("CatID") Response.Write "" & vbCrLf rso.MoveNext Wend rso.close Set rso= nothing End Sub ' Open the database connection Sub OpenDB() set dbConn1 = CreateObject("ADODB.Connection") 'set rs1 = CreateObject("ADODB.RecordSet") dbConn1.ConnectionString = Session("ConnStr") dbConn1.Open End Sub ' Close the database connection Sub CloseDB() dbConn1.Close set dbConn1 = nothing End Sub ' ************************************** ' Entry Point check the current Mode ' ************************************** If Request.Form("fEnter") = "" Then FMode = FM_ENTER NxMode = FM_CHECK fetchClientInfo Else FMode = Cint(Request.Form("fEnter")) If FMode = FM_CHECK Then ' Read the contents of the form ReadForm ' Check the Form If checkForm() = False Then FMode = FM_FORM_ERROR NxMode = FM_CHECK Else ' Send the Emails persistClientInfo FMode = sendEmail() NxMode = FM_CHECK End If End If End If %> Your comments
     
    Advanced Search Site Map View Shopping Basket
     
     
    Taste Guarantee Go to checkout
       
      your comments
      We take great pride in delivering quality food to our customers. If you would like to make suggestion about how we can help you further, or make a general comment about our service, please complete the form below and we'll get back to you as soon as possible.
     
    <% If (FMode = FM_ENTER) OR (FMode = FM_FORM_ERROR)Then %> <% If FMode = FM_FORM_ERROR Then %>

    The form is incomplete, please enter the following:

      <%=eMsg%> <% End If%>
     
    Name:
    Address:
    Post Code:
    Telephone:
    Email address:
    Your comments/suggestions:
     
      
     
    <% ElseIf FMode = FM_EMAIL_SENT Then %>

    Thank you for your enquiry.

    We will be contacting you as soon as it is possible.

     

    <% Else %>

    There has been an error sending the email.

    Please try again later.

    We thank you for your patience.

    <% End If %>