<%@LANGUAGE="VBSCRIPT"%> <% 'Dynamically set the docid session variable Session("DocID") = Request.QueryString("docid") dim errorMessage, bb1, bb2, badItem, inputArray(), j, yn redim inputArray(50,3) badItem=-1 bb1=0 bb2=0 dim conn2, strsql2, rsuser2 set conn2=server.createobject("ADODB.Connection") set rsuser2=server.createobject("ADODB.Recordset") 'direct connection conn2.open GetTestRegConnStr strSQL2 = "SELECT * FROM totals where ID=1" rsuser2.open strSQL2, conn2 ttchild = rsuser2("totchild") ttadult = rsuser2("totadult") ttboth = rsuser2("totboth") 'close resources used rsuser2.close conn2.close 'clean up set rsuser2=nothing set conn2=nothing '================================= 'All fields are acted as required ' except those the NAME of which ' is in this string variable: '================================= exceptions = Array("cmments","Address2","Country","RadioGroup1") '================================= 'NAME of the e-mail field is ' stored in this string variable: '================================= emailField = "email" emailField2 = "emailconfirm" '================================= 'Get all what is submitted '================================= yn=Request.Form("updates") IF request.Form.Count > 0 THEN execute("const numberOfFields =" & request.Form.Count) execute("redim inputArray("&numberOfFields&",3)") FOR i = 1 TO request.Form.Count inputArray(i,1) = request.Form.Key(i) inputArray(i,2) = request.Form.Item(i) inputArray(i,3) = "aa" NEXT validate END IF '================================= 'Check for empty fields '================================= SUB validate FOR i = 1 TO numberOfFields isException = False IF (inputArray(i,2)="") THEN FOR j = 0 to UBound(exceptions) IF inputArray(i,1) = exceptions(j) THEN isException = TRUE end if NEXT IF NOT isException THEN inputArray(i,3)="blank" baditem=i errorMessage = "At least one of the required fields is left empty. " END IF END IF isException = False NEXT IF (inputArray(17,2)="0") THEN inputArray(11,3)="blank" inputArray(12,3)="blank" baditem=17 errorMessage = "At least one of the required fields is left empty." end if '================================= 'Check email address '================================= validationResult = isValidEmail(inputArray(2,2)) IF validationResult <> "" THEN errorMessage = validationResult badItem = 5 bb1=1 inputArray(2,3)="blank" END IF validationResult = isValidEmail(inputArray(3,2)) IF validationResult <> "" THEN errorMessage = validationResult badItem = 6 bb2=1 inputArray(3,3)="blank" END IF 'check same address IF (ucase(inputArray(2,2)) <> ucase(inputArray(3,2))) and (bb1=0) and (bb2=0) THEN inputArray(3,3)="blank" inputArray(2,3)="blank" badItem = 6 bb1=2 bb2=2 errorMessage = "Different addresses" END IF END SUB function isValidEmail(myEmail) ' create a regular expression object dim RegExpObject set RegExpObject = New RegExp ' define the regular expression pattern for a standard email address, e.g. somebody@website.com RegExpObject.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]$" ' test the email address and return True if it matches the regular expression pattern, otherwise return False if RegExpObject.Test(myEmail) then isValidEmail ="" else isValidEmail = "Invalid Email address" end if end function '================================= 'Updated details in database '================================= sub UpdateRegister 'initialise objects and variables dim conn, strsql, rsuser set conn=server.createobject("ADODB.Connection") set rsuser=server.createobject("ADODB.Recordset") 'direct connection conn.open GetTestRegConnStr rsuser.CursorType = 2 'Set the cursor type we are using so we can navigate through the recordset rsuser.LockType = 3 'Set the lock type so that the record is locked by ADO when it is updated strSQL = "SELECT * FROM details" rsuser.open strSQL, conn rsuser.addnew rsuser("team")=Request.Form("name") rsuser("email")=Request.Form("email") rsuser("firstname")=Request.Form("firstname") rsuser("surname")=Request.Form("secondname") rsuser("address1")=Request.Form("address1") rsuser("address2")=Request.Form("address2") rsuser("town")=Request.Form("town") rsuser("postcode")=Request.Form("postcode") rsuser("adults")=CStr(Request.Form("noadult")) rsuser("children")=CStr(Request.Form("nochild")) rsuser("county")=Request.Form("county") rsuser("country")=Request.Form("country") rsuser("accommodation")=Request.Form("accommodation") rsuser("nights")=CStr(Request.Form("nights")) rsuser("cmments")=Request.Form("cmments") rsuser("updates")=Request.Form("updates") rsuser("dogs")=Request.Form("dogs") rsuser("ipaddress")=Request.ServerVariables("REMOTE_ADDR") rsuser("regdate")=FormatDateTime(now(),0) 'Write the updated recordset to the database rsuser.Update 'close resources used rsuser.close strSQL = "SELECT * FROM totals where ID=1" rsuser.open strSQL, conn rsuser("totchild") = rsuser("totchild") + Cint(Request.Form("nochild")) rsuser("totadult") = rsuser("totadult") + Cint(Request.Form("noadult")) rsuser("totboth") = rsuser("totboth") + Cint(Request.Form("nochild")) + Cint(Request.Form("noadult")) rsuser.Update 'close resources used rsuser.close conn.close 'clean up set rsuser=nothing set conn=nothing end sub '================================= 'Send out the email as it s a good form '================================= sub SendEmailOut crlf=chr(13) & chr(10) Name = Request.Form("name") SenderEmail="MegaScotlandRegistration@rumach.com" Subject = "test test test:- please ignore" Recipient=Request.Form("email") 'RecipientBCC ="registration@megascotland.co.uk" RecipientBCC = "angus@rumach.com" Body="Dear " & Request.Form("firstname") & ","& crlf Body = Body & "Thank you for registering for the Mega Scotland event and the details you entered " Body = Body & "are given below. If any of them are wrong, or if your details change, then please just " Body = Body & "reply back to us and we will alter them for you." & crlf & crlf Body = Body & "Nearer the date of the event we will send out your registration card along with other " Body = Body & "relevant details. Thanks once again for registering with us and we look forward to seeing you at " Body = Body & "Perth." & crlf & crlf Body = Body & "kind regards, " & crlf & crlf Body = Body & "The Mega Scotland team. " & crlf & crlf Body = Body & "________________________________________________________________"& crlf Body = Body &"From: " & Request.Form("name") & " [" & trim(Request.Form("email"))&"]" & crlf & crlf Body = Body & " " & Request.Form("firstname")& " " & Request.Form("secondname") & crlf Body = Body & " " & Request.Form("address1")& crlf if Request.Form("address2") <> "" then Body = Body & " " & Request.Form("address2")& crlf end if Body = Body & " " & Request.Form("town")& crlf Body = Body & " " & Request.Form("county")& crlf Body = Body & " " & Request.Form("postcode")& crlf Body = Body & " " & Request.Form("country")& crlf & crlf Body = Body & "Registered: " & CStr(Request.Form("noadult"))& " adult(s) & " & CStr(Request.Form("nochild")) & " children" & crlf & crlf Body = Body & "Accommodation: " & Request.Form("accommodation")& " for " & Request.Form("nights")& " nights." & crlf & crlf Body = Body & "Dogs: Attending with " & Request.Form("dogs") & crlf & crlf if Request.Form("updates") <> "Y" then Body = Body & "Updates: No email updates to be sent" & crlf & crlf else Body = Body & "Updates: Email updates to be sent" & crlf & crlf end if if len(Request.Form("cmments")) >1 then Body = Body & "Comments: " & Request.Form("cmments")& crlf & crlf else Body = Body & "Comments: " & crlf & crlf end if Body = Body & "________________________________________________________________" if 10 > 5 then 'set test true then send the email This is for debug purposes only Set JMail = Server.CreateObject("JMail.SMTPMail") ' Below you should enter your own SMTP-server JMail.ServerAddress = "smtp.rumach.com" JMail.Sender = Senderemail JMail.ReplyTo= SenderEmail JMail.Subject = Subject JMail.AddRecipient Recipient JMail.AddRecipientBCC RecipientBCC JMail.Body = Body JMail.Priority = 3 JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR") JMail.Logging = True JMail.Execute end if end sub %> Registration <% IF errorMessage<>"" THEN ' error detected ELSEIF request.form.count = 0 THEN 'ensure the form is clear FOR j = 0 to UBound(inputArray,1) inputArray(j,3)="" inputArray(j,2)="" inputArray(j,1)="" NEXT badItem=-1 ELSE 'To get here means that this is a vaild form so send out the email, update db etc UpdateRegister SendEmailOut %>
Registration complete.

<%=Request.Form("firstname")%>, thank you for registering and we will send a confirmation email to you shortly.
<% Response.End END IF %> 222test test test test test test test test test test test test test test
test test test test test test test test test test test test test test test
test test test test test test test test test test test test test test test
test test test test test test test test test test test test test test test

Registration

As well as logging a "Will Attend" note on the Mega event page, we are also asking you to register here so that we have an accurate count of how many people are coming to the event and so that we can send your registration pack to you.

There are also a couple of questions to do with your visit to Perthshire and these are being specifically asked by our sponsors so that they can judge the potential economic impact the event will have on the local economy.  We realise that this information can only be an approximation, and is subject to change, however your responses will be gratefully appreciated.  Similarly we have asked about dogs so that we can plan for sufficient facilities.

-1 THEN response.write "class=""errorMessage"""%>>Please note that all fields are required and if you make a mistake with your email address then we won't be able to get back to you!  

As per our privacy policy, your details will not be passed on to anyone.


Your caching name />  
Your email address > <%IF bb1=1 THEN response.write "

Invalid Email address" IF bb1=2 THEN response.write "

Email addresses"%> 

(Re-enter to confirm) > <%IF bb2=1 THEN response.write "

Invalid Email address" IF bb2=2 THEN response.write "

are not identical."%> 

First name >  
Surname />  
Address

/> />

 
Town />  
County/State />  
Post Code/Zip Code />  
Country  
No. of Adults  
No. of Children (0-16yrs)  
Whilst here for the Mega, where will you be staying?  
How many nights are you planning to be here for?  
Bringing your dog(s)?
If so how many?
 
Please email me updates from time to time

    

 
Comments / Questions / Any other information.
     


If you need to amend your registation info, just send an email to the address the confirmation email comes from.

Should your confirmation email not arrive, then please check your junk/spam folder and if its not there then contact us directly.

This form will be submitted from IP Address - <% Response.Write Request.ServerVariables("REMOTE_ADDR")%>

  <%=ttadult%>/<%=ttchild%>  <%=ttboth%>