<%@ LANGUAGE=VBScript EnableSessionState=false LCID=1033 %> <% ' -------------------------------- PRELUDE ------------------------------------- Dim Name, Email, Password, ConfirmPassword, EnableAutologin Dim CityRegion, Rent, NumBedrooms, AdText ' ------------------------------- PRE-PAGE ------------------------------------- Sub PrePage General_PrePage() ' -------------------------- ' Setup Page Variables ' -------------------------- Page.Title = "Registration" Page.HideToolbar = HIDE_TOOLBAR End Sub ' ------------------------------- POST-PAGE ------------------------------------ Sub PostPage General_PostPage() End Sub ' ------------------------------ VALIDATION ------------------------------------ Sub Validation Dim SQL Dim ClientAlreadyExists Dim ClientID, AdsPurchased, AdsUsed, DaysToExpiration, RecordLogin Dim ExpirationDate ' -------------------------- ' Read Form Inputs ' -------------------------- Name = ParseFormText("Name", "", null) Email = ParseFormText("Email", "", null) Password = ParseFormText("Password", "", null) ConfirmPassword = ParseFormText("ConfirmPassword", "", null) EnableAutologin = ParseFormBoolean("EnableAutologin", False, null) CityRegion = ParseFormText("CityRegion", null, null) Rent = ParseFormInteger("Rent", null, null) NumBedrooms = ParseFormDouble("NumBedrooms", null, null) AdText = ParseFormText("AdText", null, null) ' -------------------------- ' Validate Form Fields ' -------------------------- FormCheckRequired "Name", "You must enter a name." FormCheckEmail "Email", "You must enter a valid e-mail address." FormCheckTextLength "Password", 3, 20, "Your password must be at least 3 characters long.", "Your password cannot be longer than 20 characters." If (Password <> ConfirmPassword) Then AddError "ConfirmPassword", "Your password and confirm password must match." End If If (IsBlank(Trim(CityRegion)) Or IsBlank(LookupListLabel("city_regions", CityRegion))) Then AddError "CityRegion", "You must select a city region." End If FormCheckTextLength "AdText", 1, 4000, "You must enter ad text.", "Your ad text cannot be longer than 4,000 characters." ' -------------------------- ' If no errors, continue ' -------------------------- If (Not ErrorsExist()) then ' -------------------------- ' Check if user exists ' -------------------------- ClientAlreadyExists = CallSQLProcWithReturn("pr_Client_Exists", Database.Conn, Database.Rs, FormatSQLText(Email)) If (ClientAlreadyExists = 0) Then Database.BeginTrans() ' -------------------------- ' Save Client ' -------------------------- AdsPurchased = GetConfigVar("Applications.Classifieds.DefaultAdsPurchased") AdsUsed = 1 ClientID = CallSQLProcWithReturn("pr_Client_Add", Database.Conn, Database.Rs, _ FormatSQLText(Name), _ FormatSQLText(Email), _ FormatSQLText(Password), _ FormatSQLInteger(AdsPurchased), _ FormatSQLInteger(AdsUsed)) ' -------------------------- ' Save Ad ' -------------------------- DaysToExpiration = GetConfigVar("Applications.Classifieds.DefaultDaysToExpiration") ExpirationDate = DateOnly(DateAdd("d", DaysToExpiration, Now())) SQL = "INSERT INTO t_Ad_Classifieds (client_id, expiration_date, rent, num_bedrooms, city_region," &_ " content) VALUES (" &_ FormatSQLInteger(ClientID) & ", " &_ FormatSQLDate(ExpirationDate) & ", " &_ FormatSQLDouble(Rent) & ", " &_ FormatSQLInteger(NumBedrooms) & ", " &_ FormatSQLText(CityRegion) & ", " &_ FormatSQLText(AdText) & ")" Database.Execute SQL Database.CommitTrans() ' -------------------------- ' Setup Session ' -------------------------- ResetSession() RecordLogin = False DoLogin ClientID, Email, RecordLogin ' ***NOTE*** ' UserID, Username and Email are setup in the DoLogin procedure above ' SetSessionVar "Name", Name ' -------------------------- ' Setup Autologin ' -------------------------- If (EnableAutologin) Then SetAutoLogin() End If ' -------------------------- ' Redirect ' -------------------------- RedirectTo("clients/home.asp") Else AddError "Email", "The e-mail address '" & Email & "' has already been registered. Please log in using the existing account." End If End If End Sub ' -------------------------------- OUTPUT -------------------------------------- Sub Output %>
<% DisplayErrors %>

<%= FormStart() %>
<%= bt_BarHeading %> Account Info <%= et_BarHeading %>
<%= bt_NormalText %> Enter your name, e-mail and password below. Your password must be at least 3 characters long. <%= et_NormalText %>
<%= bt_FormFieldLabel %> <% HighlightOnError "Name", "Name:" %> <%= et_FormFieldLabel %> <%= FormTextInput("Name", Name, 30, 50) %>
<%= bt_FormFieldLabel %> <% HighlightOnError "Email", "E-mail:" %> <%= et_FormFieldLabel %> <%= FormTextInput("Email", Email, 30, 50) %>
<%= bt_FormFieldLabel %> <% HighlightOnError "Password", "Password:" %> <%= et_FormFieldLabel %> <%= FormPasswordInput("Password", Password, 20, 20) %>
<%= bt_FormFieldLabel %> <% HighlightOnError "ConfirmPassword", "Confirm Password:" %> <%= et_FormFieldLabel %> <%= FormPasswordInput("ConfirmPassword", ConfirmPassword, 20, 20) %>
<%= FormCheckBox("EnableAutologin", EnableAutologin, True) %> <%= bt_NormalText %> Save my info on this computer so I don't have to log in again. (Not recommended for users who use a shared computer). <%= et_NormalText %>
 
<%= bt_BarHeading %> Classified Ad Info <%= et_BarHeading %>
<%= bt_NormalText %> Enter the information for your ad below. Only the ad text will be displayed; however, rent, number of bedrooms and other information will be used to search for the ad. <%= et_NormalText %>
<%= bt_FormFieldLabel %> <% HighlightOnError "CityRegion", "Region:" %> <%= et_FormFieldLabel %> <%= AdvancedFormSelect_List("CityRegion", CityRegion, "city_regions", Null, False, "-- Select One--", "", Null, Null, Null) %>
<%= bt_FormFieldLabel %> <% HighlightOnError "Rent", "Rent:" %> <%= et_FormFieldLabel %> <%= FormTextInput("Rent", Rent, 10, 10) %>
<%= bt_FormFieldLabel %> <% HighlightOnError "NumBedrooms", "# of Bedrooms:" %> <%= et_FormFieldLabel %> <%= FormTextInput("NumBedrooms", NumBedrooms, 10, 10) %>
<%= bt_FormFieldLabel %> <% HighlightOnError "AdText", "Ad Text:" %> <%= et_FormFieldLabel %> <%= FormTextArea("AdText", AdText, 5, 50, "physical") %>

<% End Sub %>