%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% 'Make a transaction dispatcher instance Dim tNGs: Set tNGs = new tNG_dispatcher tNGs.Init "" %> <% ' Start trigger Dim formValidation: Set formValidation = new tNG_FormValidation formValidation.Init formValidation.addField "first_name", true, "text", "", "", "", "Please enter your first name." formValidation.addField "last_name", true, "text", "", "", "", "Please enter your last name." formValidation.addField "email", true, "text", "email", "", "", "Please enter a valid email address." formValidation.addField "phone", true, "regexp", "/^\d{10}$/", "", "", "Please enter a 10 digit phone number." formValidation.addField "booking_date", true, "date", "date", "", "", "Please enter a valid date." formValidation.addField "guests", true, "numeric", "int", "0", "", "Please enter the number of guests." tNGs.prepareValidation formValidation ' End trigger %><% 'start Trigger_SendEmail trigger 'remove this line if you want to edit the code by hand Function Trigger_SendEmail (ByRef tNG) Dim emailObj: Set emailObj = new tNG_Email emailObj.Init tNG emailObj.setFrom "{email}" emailObj.setTo "info@lornehotel.com.au" emailObj.setCC "" emailObj.setBCC "" emailObj.setSubject "Online Bistro Booking" 'FromFile method emailObj.setContentFile "email_blank_bistro.html" emailObj.setEncoding "ISO-8859-1" emailObj.setFormat "HTML/Text" emailObj.setImportance "Normal" Set Trigger_SendEmail = emailObj.Execute() End Function 'end Trigger_SendEmail trigger %> <% ' Make an insert transaction instance Dim ins_tblbistrobooking: Set ins_tblbistrobooking = new tNG_insert ins_tblbistrobooking.init MM_lorne_hotel_STRING tNGs.addTransaction ins_tblbistrobooking ' Register triggers ins_tblbistrobooking.registerTrigger Array("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1") ins_tblbistrobooking.registerTrigger Array("BEFORE", "Trigger_Default_FormValidation", 10, formValidation) ins_tblbistrobooking.registerTrigger Array("END", "Trigger_Default_Redirect", 99, "thankyou.htm") ins_tblbistrobooking.registerTrigger Array("AFTER", "Trigger_SendEmail", 40) ' Add columns ins_tblbistrobooking.setTable "tblbistrobooking" ins_tblbistrobooking.addColumn "first_name", "STRING_TYPE", "POST", "first_name", "" ins_tblbistrobooking.addColumn "last_name", "STRING_TYPE", "POST", "last_name", "" ins_tblbistrobooking.addColumn "email", "STRING_TYPE", "POST", "email", "" ins_tblbistrobooking.addColumn "phone", "STRING_TYPE", "POST", "phone", "" ins_tblbistrobooking.addColumn "booking_date", "DATE_TYPE", "POST", "booking_date", "" ins_tblbistrobooking.addColumn "guests", "NUMERIC_TYPE", "POST", "guests", "" ins_tblbistrobooking.addColumn "message", "STRING_TYPE", "POST", "message", "" ins_tblbistrobooking.addColumn "date_submitted", "DATE_TYPE", "POST", "date_submitted", "{NOW}" ins_tblbistrobooking.setPrimaryKey "booking_id", "NUMERIC_TYPE", "", "" %> <% 'Execute all the registered transactions tNGs.executeTransactions %> <% 'Get the transaction recordset Dim rstblbistrobooking Dim rstblbistrobooking_numRows Set rstblbistrobooking = tNGs.getRecordset("tblbistrobooking") rstblbistrobooking_numRows = 0 %>
|