%Option Explicit%> <%response.buffer = true%> <% 'Variables for page dim i 'Counter for various for loops 'Variables for database connection dim objConn set objConn = Server.CreateObject("ADODB.Connection") objConn.Open CONNECTION_STRING 'Form variables (from membership.asp) - will be null unless the form has posted to itself dim firstname, lastname, email, address1, address2, city, province, postalcode, areacode, phoneprefix, phonesuffix dim birthmonth, birthday, birthyear, gender, handicap, rounds, newsletter, checkedStr, bitNewsletter firstname = Request.Form("FirstName") lastname = Request.Form("LastName") email = Request.Form("Email") address1 = Request.Form("Address1") address2 = Request.Form("Address2") city = Request.Form("City") province = Request.Form("Province") postalcode = Request.Form("PostalCode") areacode = Request.Form("AreaCode") phoneprefix = Request.Form("PhonePrefix") phonesuffix = Request.Form("PhoneSuffix") birthmonth = Request.Form("Month") birthday = Request.Form("Date") birthyear = Request.Form("Year") gender = Request.Form("Gender") handicap = Request.Form("Handicap") rounds = Request.Form("RoundsPerYear") newsletter = Request.Form("Newsletter") 'bitNewsletter defaults to true for firsttime visitors bitNewsletter = true 'If this page has posted to itself, then try to add to database if Request.Form("Action") = "Insert" then 'Format birthdate & phone and optional fields newsletter, handicap & rounds dim birthdate, numHandicap, numRounds, phone if Trim(birthmonth & birthday & birthyear) <> "" then on error resume next birthdate = "#" & CDate(birthmonth & " " & birthday & ", " & birthyear) & "#" if err then birthdate = "NULL" end if on error goto 0 else birthdate = "NULL" end if phone = "(" & areacode & ") " & phoneprefix & "-" & phonesuffix if newsletter = "on" then bitNewsletter = true else bitNewsletter = false end if if handicap = "" then numHandicap = "NULL" else numHandicap = handicap end if if rounds = "" then numRounds = "NULL" else numRounds = rounds end if 'Prepare SQL dim insertSQL insertSQL = "INSERT INTO membership (Email, Lastname, Firstname, Address1, Address2, City, Province, PostalCode, Phone, Birthdate, Gender, Handicap, RoundsPerYear, Newsletter) VALUES" & chr(10) _ & "('" & Replace(email, "'", "''") & "', " & chr(10) _ & "'" & Replace(lastname, "'", "''") & "', " & chr(10) _ & "'" & Replace(firstname, "'", "''") & "', " & chr(10) _ & "'" & Replace(address1, "'", "''") & "', " & chr(10) _ & "'" & Replace(address2, "'", "''") & "', " & chr(10) _ & "'" & Replace(city, "'", "''") & "', " & chr(10) _ & "'" & Replace(province, "'", "''") & "', " & chr(10) _ & "'" & Replace(postalcode, "'", "''") & "', " & chr(10) _ & "'" & phone & "', " & chr(10) _ & birthdate & ", " & chr(10) _ & "'" & gender & "', " & chr(10) _ & numHandicap & ", " & chr(10) _ & numRounds & ", " & chr(10) _ & bitNewsletter & ")" 'Run the insert query on error resume next objConn.Execute(insertSQL) on error goto 0 'Any errors? dim dbError, currentTime if objConn.Errors.Count <> 0 then currentTime = Now() for each dbError in objConn.Errors if dbError.Number = PK_ERROR then errorList.Add "There is a user with that email address already registered with golfthedunes.com!" else errorList.Add "Please contact info@golfthedunes.com to report this error (" & currentTime & ")" addToErrorLog dbError.Number, dbError.Description, currentTime end if next else Response.Redirect "thanks.asp" end if end if 'Variables for province query dim objProvRs, sqlStmt, provList set objProvRs = Server.CreateObject("ADODB.RecordSet") sqlStmt = "SELECT ProvinceCode, Name FROM ProvCountry ORDER BY Country, Name" set objProvRs = objConn.Execute(sqlStmt) provList = "" do while not objProvRs.EOF if objProvRs("ProvinceCode") = province then provList = provList & "" & chr(10) else provList = provList & "" & chr(10) end if objProvRs.MoveNext loop objProvRs.Close set objProvRs = nothing 'Close database connection object objConn.Close set objConn = nothing %>
![]() |
|
Win Free Golf at "The Dunes At Kamloops!"Beginning in January of 2001 we will be giving away free rounds of golf. Sign up today for your automatic entry into Golf The Dunes FREE GOLF GIVEAWAY contest.Every month we will be giving away a green fee for two and a cart rental. Click here to sign up and WIN. Free BenefitsJoining www.GolfTheDunes.com has many benefits including:
" & chr(10) Response.Write "
" & chr(10) next Response.Write " |