I have this code as part of the action that sends details to admin and user who have registered...

However, I would like the email to be sent also to other address based on the selection in this field..(sectorID) the form has 9 sectors, I.e.

  • sector ID 1
  • sector ID 2
  • sector ID 3
  • sector ID 5
  • sector ID 6
  • sector ID 7
  • sector ID 8
  • sector ID 9

The emails to the user and the admin works pretty well but I have been un able to work on the other option..

Please help...

'// send email to user
message="You have registered as user at" & " " & url & vbcrlf
' strLabel = "Username"
strLabel = "Username"
message=message & strLabel & ": " & values.Item("username") & vbcrlf
' strLabel = "Passowrd"
strLabel = "Passowrd"
message=message & strLabel & ": " & values.Item("passowrd") & vbcrlf
' strLabel = "Email"
strLabel = "Email"
message=message & strLabel & ": " & values.Item("Email") & vbcrlf
' strLabel = "Sector Name"
strLabel = "Sector Name"
message=message & strLabel & ": " & values.Item("sectorID") & vbcrlf
' strLabel = "Staff Name"
strLabel = "Staff Name"
message=message & strLabel & ": " & values.Item("Staff_Name") & vbcrlf
' strLabel = "Extension"
strLabel = "Extension"
message=message & strLabel & ": " & values.Item("Extension") & vbcrlf
' strLabel = "Mobile Number"
strLabel = "Mobile Number"
message=message & strLabel & ": " & values.Item("Mobile_Number") & vbcrlf
' strLabel = "Land Line Number"
strLabel = "Land Line Number"
message=message & strLabel & ": " & values.Item("Land_Line_Number") & vbcrlf
' strLabel = "Alternative Number"
strLabel = "Alternative Number"
message=message & strLabel & ": " & values.Item("Alternative_Number") & vbcrlf
' strLabel = "Other Email Address"
strLabel = "Other Email Address"
message=message & strLabel & ": " & values.Item("Other_Email_Address") & vbcrlf
' strLabel = "Location (Street, Number)"
strLabel = "Location (Street, Number)"
message=message & strLabel & ": " & values.Item("Location") & vbcrlf
' strLabel = "Residential Area"
strLabel = "Residential Area"
message=message & strLabel & ": " & values.Item("Residential_Area") & vbcrlf
' strLabel = "Closest Police Sation"
strLabel = "Closest Police Sation"
message=message & strLabel & ": " & values.Item("Closest_ Police_Sation") & vbcrlf
Call sendmail(Email,"Notification on registering",message)

'// send letter to admin
message="User registered at" & " " & url & vbcrlf
' strLabel = "Username"
strLabel = "Username"
message=message & strLabel & ": " & values.Item("username") & vbcrlf
' strLabel = "Email"
strLabel = "Email"
message=message & strLabel & ": " & values.Item("Email") & vbcrlf
' strLabel = "Sector Name"
strLabel = "Sector Name"
message=message & strLabel & ": " & values.Item("sectorID") & vbcrlf
' strLabel = "Staff Name"
strLabel = "Staff Name"
message=message & strLabel & ": " & values.Item("Staff_Name") & vbcrlf
' strLabel = "Extension"
strLabel = "Extension"
message=message & strLabel & ": " & values.Item("Extension") & vbcrlf
' strLabel = "Mobile Number"
strLabel = "Mobile Number"
message=message & strLabel & ": " & values.Item("Mobile_Number") & vbcrlf
' strLabel = "Land Line Number"
strLabel = "Land Line Number"
message=message & strLabel & ": " & values.Item("Land_Line_Number") & vbcrlf
' strLabel = "Alternative Number"
strLabel = "Alternative Number"
message=message & strLabel & ": " & values.Item("Alternative_Number") & vbcrlf
' strLabel = "Other Email Address"
strLabel = "Other Email Address"
message=message & strLabel & ": " & values.Item("Other_Email_Address") & vbcrlf
' strLabel = "Location (Street, Number)"
strLabel = "Location (Street, Number)"
message=message & strLabel & ": " & values.Item("Location") & vbcrlf
' strLabel = "Residential Area"
strLabel = "Residential Area"
message=message & strLabel & ": " & values.Item("Residential_Area") & vbcrlf
' strLabel = "Closest Police Sation"
strLabel = "Closest Police Sation"
message=message & strLabel & ": " & values.Item("Closest_ Police_Sation") & vbcrlf
Call sendmail("admin@admin.com","Notification on registering",message)

You figured the main part, so the rest should be easy for you.

Like some case select options to define [option_email] from your sectorID and then...

Call sendmail("option_email","Notification on registering",message)

Or you trying to send to multiple options at the same time?

Hi ArtistScope,

Thanks so much for your reply, I would like more of your assistance on the way I can do the case select options to define [option_email] from the sectorID in the form as you have suggested, coz to be honest, I have never used that... The reason why I can send the email all at once to different email addresses is because, there should be only three stages of email sent, one should be to the user who have registered, second is to the Main admin which is working now, and the third is to the admin of the sector ID selected by the user... This is some sort of address book system and users are divided in to sectors with their own admin... so if a user registers to sector 1, the admin in sector 1 should receive a notification, same as if the user registers in sector 5, only the admin in sector 5 gets the notification,,, I hope I am understood

This the whole code in the registration page.......

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Warden_system_default.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="1" bordercolor="#FFFFFF">
      <tr>
        <td height="133" bgcolor="#DFEAF5"><img src="images/warden-headertextgif.gif" alt="WARDEN SYSTEM" width="770" height="133" />          </td>
      </tr>
      <tr>
        <td height="10" background="login.asp" bgcolor="#FFFFFF"><p></td>
      </tr>
      <tr valign="top">
        <td bgcolor="#FFFFFF"><div id="tables_block">
  <!-- InstanceBeginEditable name="content" --><!--#include file="include/dbcommon.asp"-->
<!--#include file="include/Staff_Details_variables.asp"-->
<!--#include file="include/md5.asp"-->
<!--#include file="libs/xtempl.asp"-->
<%
dim xt
set xt = new XTempl

    Set myRequest = CreateObject("Scripting.Dictionary")
    Set myRequestFiles = CreateObject("Scripting.Dictionary")
    if ParseMultiPartForm()=true then parse=1

registered=false
onload=" "
Message=""
Username=""
Password=""
Email=""


set values = CreateObject("Scripting.Dictionary")
dbConnection=""
db_connect()

DoEvent "BeforeProcessRegister dbConnection"




if getrequestform("btnSubmit") = "Register" then


    Set rs = server.CreateObject("ADODB.Recordset")

    set filename_values = CreateObject("Scripting.Dictionary")


'// processing username - start

    value = postvalue("value_username")
    ttype=postvalue("type_username")
    toadd=true
if myRequest.Exists("value_username") or myRequest.Exists("value_username[]") or myRequest.Exists("type_username") then
            value=prepare_for_db("username",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("username") = value
        end if
    end if
'// processibng username - end

'// processing passowrd - start

    value = postvalue("value_passowrd")
    ttype=postvalue("type_passowrd")
    toadd=true
if myRequest.Exists("value_passowrd") or myRequest.Exists("value_passowrd[]") or myRequest.Exists("type_passowrd") then
            value=prepare_for_db("passowrd",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("passowrd") = value
        end if
    end if
'// processibng passowrd - end

'// processing Email - start

    value = postvalue("value_Email")
    ttype=postvalue("type_Email")
    toadd=true
if myRequest.Exists("value_Email") or myRequest.Exists("value_Email[]") or myRequest.Exists("type_Email") then
            value=prepare_for_db("Email",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Email") = value
        end if
    end if
'// processibng Email - end

'// processing sectorID - start

    value = postvalue("value_sectorID")
    ttype=postvalue("type_sectorID")
    toadd=true
if myRequest.Exists("value_sectorID") or myRequest.Exists("value_sectorID[]") or myRequest.Exists("type_sectorID") then
            value=prepare_for_db("sectorID",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("sectorID") = value
        end if
    end if
'// processibng sectorID - end

'// processing Staff_Name - start

    value = postvalue("value_Staff_Name")
    ttype=postvalue("type_Staff_Name")
    toadd=true
if myRequest.Exists("value_Staff_Name") or myRequest.Exists("value_Staff_Name[]") or myRequest.Exists("type_Staff_Name") then
            value=prepare_for_db("Staff_Name",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Staff_Name") = value
        end if
    end if
'// processibng Staff_Name - end

'// processing Extension - start

    value = postvalue("value_Extension")
    ttype=postvalue("type_Extension")
    toadd=true
if myRequest.Exists("value_Extension") or myRequest.Exists("value_Extension[]") or myRequest.Exists("type_Extension") then
            value=prepare_for_db("Extension",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Extension") = value
        end if
    end if
'// processibng Extension - end

'// processing Mobile_Number - start

    value = postvalue("value_Mobile_Number")
    ttype=postvalue("type_Mobile_Number")
    toadd=true
if myRequest.Exists("value_Mobile_Number") or myRequest.Exists("value_Mobile_Number[]") or myRequest.Exists("type_Mobile_Number") then
            value=prepare_for_db("Mobile_Number",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Mobile_Number") = value
        end if
    end if
'// processibng Mobile_Number - end

'// processing Land_Line_Number - start

    value = postvalue("value_Land_Line_Number")
    ttype=postvalue("type_Land_Line_Number")
    toadd=true
if myRequest.Exists("value_Land_Line_Number") or myRequest.Exists("value_Land_Line_Number[]") or myRequest.Exists("type_Land_Line_Number") then
            value=prepare_for_db("Land_Line_Number",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Land_Line_Number") = value
        end if
    end if
'// processibng Land_Line_Number - end

'// processing Alternative_Number - start

    value = postvalue("value_Alternative_Number")
    ttype=postvalue("type_Alternative_Number")
    toadd=true
if myRequest.Exists("value_Alternative_Number") or myRequest.Exists("value_Alternative_Number[]") or myRequest.Exists("type_Alternative_Number") then
            value=prepare_for_db("Alternative_Number",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Alternative_Number") = value
        end if
    end if
'// processibng Alternative_Number - end

'// processing Other_Email_Address - start

    value = postvalue("value_Other_Email_Address")
    ttype=postvalue("type_Other_Email_Address")
    toadd=true
if myRequest.Exists("value_Other_Email_Address") or myRequest.Exists("value_Other_Email_Address[]") or myRequest.Exists("type_Other_Email_Address") then
            value=prepare_for_db("Other_Email_Address",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Other_Email_Address") = value
        end if
    end if
'// processibng Other_Email_Address - end

'// processing Location - start

    value = postvalue("value_Location")
    ttype=postvalue("type_Location")
    toadd=true
if myRequest.Exists("value_Location") or myRequest.Exists("value_Location[]") or myRequest.Exists("type_Location") then
            value=prepare_for_db("Location",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Location") = value
        end if
    end if
'// processibng Location - end

'// processing Residential_Area - start

    value = postvalue("value_Residential_Area")
    ttype=postvalue("type_Residential_Area")
    toadd=true
if myRequest.Exists("value_Residential_Area") or myRequest.Exists("value_Residential_Area[]") or myRequest.Exists("type_Residential_Area") then
            value=prepare_for_db("Residential_Area",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Residential_Area") = value
        end if
    end if
'// processibng Residential_Area - end

'// processing Closest_ Police_Sation - start

    value = postvalue("value_Closest__Police_Sation")
    ttype=postvalue("type_Closest__Police_Sation")
    toadd=true
if myRequest.Exists("value_Closest__Police_Sation") or myRequest.Exists("value_Closest__Police_Sation[]") or myRequest.Exists("type_Closest__Police_Sation") then
            value=prepare_for_db("Closest_ Police_Sation",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Closest_ Police_Sation") = value
        end if
    end if
'// processibng Closest_ Police_Sation - end


Username = postvalue("value_username")
Password = postvalue("value_passowrd")

    Email = values.Item("Email")

'// add filenames to values
    for each key in filename_values
        values(key)=filename_values.Item(key)
    next

'   check if entered username already exists
    if len(Username)=0 then 
        if Message<>"" then Message=Message & "<br>"
        Message=Message & "Username can not be empty."
    else
        strSQL="select count(*) from [Staff Details] where [username]=" & add_db_quotes("username",Username)
        rs.Open strSQL,dbConnection
        if not rs.EOF then
            if CLng(rs(0))>0 then
                Message="Username" & " <i>" & Username & "</i> " & "already exists. Choose another username."
            end if
        end if
        rs.close
    end if


'// check if entered email already exists

    if len(Email)=0 then 
        if Message<>"" then Message=Message & "<br>"
        Message=Message & "Please enter valid email address."
    else
        strSQL="select count(*) from [Staff Details] where [Email]=" & add_db_quotes("Email", Email)
        rs.Open strSQL,dbConnection
        if not rs.EOF then
            if CLng(rs(0))>0 then
                if Message<>"" then Message=Message & "<br>"
                Message=Message & "Email" & " <i>" & Email & "</i> " & "already registered. If you forgot your username or password use the password reminder form."
            end if
        end if
        rs.close
    end if

    if not checkpassword(values("passowrd")) then
        if Message<>"" then Message=Message & "<br>"
        dim fmt
        fmt="Password must be at least %% characters length."
        fmt=replace(fmt,"%%","5")
        Message = Message & "<br>" & fmt
    end if


    retval=true
    if Message="" then DoEvent "retval = BeforeRegister(values)"

    if Message="" and  retval then

'   //  encrypt password
    originalpassword=values.Item("passowrd")
    values.Item("passowrd") = md5(values.Item("passowrd"))

' insert new user

    rs.Open "select * from [Staff Details] where 1=0", dbConnection, 1,2
    rs.Addnew
'   insert StaffID field
    strValue=false
    if values.exists("StaffID") then    _
        strValue = values.Item("StaffID")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_StaffID")
                                if strValue<>"" and IsNumeric(strValue) then 
            rs("StaffID") = CLng(strValue)
        else
            rs("StaffID") = null
        end if
    end if
'   insert Staff_Name field
    strValue=false
    if values.exists("Staff_Name") then     _
        strValue = values.Item("Staff_Name")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Staff_Name")
                                rs("Staff_Name") = strValue                 
    end if
'   insert Email field
    strValue=false
    if values.exists("Email") then  _
        strValue = values.Item("Email")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Email")
                                rs("Email") = strValue                  
    end if
'   insert Extension field
    strValue=false
    if values.exists("Extension") then  _
        strValue = values.Item("Extension")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Extension")
                                rs("Extension") = strValue                  
    end if
'   insert Mobile_Number field
    strValue=false
    if values.exists("Mobile_Number") then  _
        strValue = values.Item("Mobile_Number")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Mobile_Number")
                                rs("Mobile_Number") = strValue                  
    end if
'   insert Land_Line_Number field
    strValue=false
    if values.exists("Land_Line_Number") then   _
        strValue = values.Item("Land_Line_Number")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Land_Line_Number")
                                rs("Land_Line_Number") = strValue                   
    end if
'   insert Alternative_Number field
    strValue=false
    if values.exists("Alternative_Number") then     _
        strValue = values.Item("Alternative_Number")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Alternative_Number")
                                rs("Alternative_Number") = strValue                 
    end if
'   insert Other_Email_Address field
    strValue=false
    if values.exists("Other_Email_Address") then    _
        strValue = values.Item("Other_Email_Address")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Other_Email_Address")
                                rs("Other_Email_Address") = strValue                    
    end if
'   insert Location field
    strValue=false
    if values.exists("Location") then   _
        strValue = values.Item("Location")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Location")
                                rs("Location") = strValue                   
    end if
'   insert Residential_Area field
    strValue=false
    if values.exists("Residential_Area") then   _
        strValue = values.Item("Residential_Area")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Residential_Area")
                                rs("Residential_Area") = strValue                   
    end if
'   insert WardenID field
    strValue=false
    if values.exists("WardenID") then   _
        strValue = values.Item("WardenID")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_WardenID")
                                if strValue<>"" and IsNumeric(strValue) then 
            rs("WardenID") = CLng(strValue)
        else
            rs("WardenID") = null
        end if
    end if
'   insert Closest_ Police_Sation field
    strValue=false
    if values.exists("Closest_ Police_Sation") then     _
        strValue = values.Item("Closest_ Police_Sation")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Closest__Police_Sation")
                                rs("Closest_ Police_Sation") = strValue                 
    end if
'   insert username field
    strValue=false
    if values.exists("username") then   _
        strValue = values.Item("username")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_username")
                                rs("username") = strValue                   
    end if
'   insert passowrd field
    strValue=false
    if values.exists("passowrd") then   _
        strValue = values.Item("passowrd")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_passowrd")
                                rs("passowrd") = strValue                   
    end if
'   insert sectorID field
    strValue=false
    if values.exists("sectorID") then   _
        strValue = values.Item("sectorID")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_sectorID")
                                if strValue<>"" and IsNumeric(strValue) then 
            rs("sectorID") = CLng(strValue)
        else
            rs("sectorID") = null
        end if
    end if
    rs.Update

    values.Item("passowrd")=originalpassword
        DoEvent "AfterSuccessfulRegistration values"

        url = "http://" & request.ServerVariables("SERVER_NAME")
        if CStr(request.ServerVariables("SERVER_PORT"))<>"80" then _
            url = url & ":" & request.ServerVariables("SERVER_PORT")
        url= url & request.ServerVariables("SCRIPT_NAME")
'// send email to user
        message="You have registered as user at" & " " & url & vbcrlf
'       strLabel = "Username"
        strLabel = "Username"
        message=message & strLabel & ": " & values.Item("username") & vbcrlf
'       strLabel = "Passowrd"
        strLabel = "Passowrd"
        message=message & strLabel & ": " & values.Item("passowrd") & vbcrlf
'       strLabel = "Email"
        strLabel = "Email"
        message=message & strLabel & ": " & values.Item("Email") & vbcrlf
'       strLabel = "Sector Name"
        strLabel = "Sector Name"
        message=message & strLabel & ": " & values.Item("sectorID") & vbcrlf
'       strLabel = "Staff Name"
        strLabel = "Staff Name"
        message=message & strLabel & ": " & values.Item("Staff_Name") & vbcrlf
'       strLabel = "Extension"
        strLabel = "Extension"
        message=message & strLabel & ": " & values.Item("Extension") & vbcrlf
'       strLabel = "Mobile Number"
        strLabel = "Mobile Number"
        message=message & strLabel & ": " & values.Item("Mobile_Number") & vbcrlf
'       strLabel = "Land Line Number"
        strLabel = "Land Line Number"
        message=message & strLabel & ": " & values.Item("Land_Line_Number") & vbcrlf
'       strLabel = "Alternative Number"
        strLabel = "Alternative Number"
        message=message & strLabel & ": " & values.Item("Alternative_Number") & vbcrlf
'       strLabel = "Other Email Address"
        strLabel = "Other Email Address"
        message=message & strLabel & ": " & values.Item("Other_Email_Address") & vbcrlf
'       strLabel = "Location (Street, Number)"
        strLabel = "Location (Street, Number)"
        message=message & strLabel & ": " & values.Item("Location") & vbcrlf
'       strLabel = "Residential Area"
        strLabel = "Residential Area"
        message=message & strLabel & ": " & values.Item("Residential_Area") & vbcrlf
'       strLabel = "Closest Police Sation"
        strLabel = "Closest Police Sation"
        message=message & strLabel & ": " & values.Item("Closest_ Police_Sation") & vbcrlf
        Call sendmail(Email,"Notification on registering",message)

'// send letter to admin
        message="User registered at" & " " & url & vbcrlf
'       strLabel = "Username"
        strLabel = "Username"
        message=message & strLabel & ": " & values.Item("username") & vbcrlf
'       strLabel = "Email"
        strLabel = "Email"
        message=message & strLabel & ": " & values.Item("Email") & vbcrlf
'       strLabel = "Sector Name"
        strLabel = "Sector Name"
        message=message & strLabel & ": " & values.Item("sectorID") & vbcrlf
'       strLabel = "Staff Name"
        strLabel = "Staff Name"
        message=message & strLabel & ": " & values.Item("Staff_Name") & vbcrlf
'       strLabel = "Extension"
        strLabel = "Extension"
        message=message & strLabel & ": " & values.Item("Extension") & vbcrlf
'       strLabel = "Mobile Number"
        strLabel = "Mobile Number"
        message=message & strLabel & ": " & values.Item("Mobile_Number") & vbcrlf
'       strLabel = "Land Line Number"
        strLabel = "Land Line Number"
        message=message & strLabel & ": " & values.Item("Land_Line_Number") & vbcrlf
'       strLabel = "Alternative Number"
        strLabel = "Alternative Number"
        message=message & strLabel & ": " & values.Item("Alternative_Number") & vbcrlf
'       strLabel = "Other Email Address"
        strLabel = "Other Email Address"
        message=message & strLabel & ": " & values.Item("Other_Email_Address") & vbcrlf
'       strLabel = "Location (Street, Number)"
        strLabel = "Location (Street, Number)"
        message=message & strLabel & ": " & values.Item("Location") & vbcrlf
'       strLabel = "Residential Area"
        strLabel = "Residential Area"
        message=message & strLabel & ": " & values.Item("Residential_Area") & vbcrlf
'       strLabel = "Closest Police Sation"
        strLabel = "Closest Police Sation"
        message=message & strLabel & ": " & values.Item("Closest_ Police_Sation") & vbcrlf
        Call sendmail("erick.otieno@unhabitat.org","Notification on registering",message)



'// show Registartion successful message

        set body=CreateObject("Scripting.Dictionary")
        body("begin")="<form method=""POST"" action=""login.asp"" name=""loginform"">"
        body("begin")=body("begin") & "<input type=""Hidden"" name=username value=""" & my_htmlspecialchars(Username) & """>"
        body("begin")=body("begin") & "<input type=""Hidden"" name=password value=""" & my_htmlspecialchars(Password) & """>"
        body("begin")=body("begin") & "</form>"
        xt.assign "registered_block",true
        xt.assign "body",body
        xt.assign "loginlink_attrs","onclick=""document.forms.loginform.submit();return false;"""
        xt.display("register_success.htm")
        response.End
    else
        DoEvent "AfterUnsuccessfulRegistration values"
    end if

    if message<>"" then
        xt.assign "message",message
        xt.assign "message_block",true
        end if
end if

'//send to warden in sector1


'// validation stuff
bodyonload=""
onsubmit=""
includes=""

includes=includes & "<script language=""JavaScript"" src=""include/validate.js""></script>" & vbcrlf
includes=includes & "<script language=""JavaScript"">" & vbcrlf
includes=includes & "var TEXT_FIELDS_REQUIRED=""" & addslashes("The Following fields are Required") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_ZIPCODES=""" & addslashes("") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_EMAILS=""" & addslashes("The Following fields must be valid Emails") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_NUMBERS=""" & addslashes("The Following fields must be Numbers") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_CURRENCY=""" & addslashes("The Following fields must be currency") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_PHONE=""" & addslashes("The Following fields must be Phone Numbers") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_PASSWORD1=""" & addslashes("The Following fields must be valid Passwords") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_PASSWORD2=""" & addslashes("should be at least 4 characters long") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_PASSWORD3=""" & addslashes("Cannot be 'password'") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_STATE=""" & addslashes("The Following fields must be State Names") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_SSN=""" & addslashes("The Following fields must be Social Security Numbers") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_DATE=""" & addslashes("The Following fields must be valid dates") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_TIME=""" & addslashes("The Following fields must be valid time in 24-hours format") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_CC=""" & addslashes("The Following fields must be valid Credit Card Numbers") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_SSN=""" & addslashes("The Following fields must be Social Security Numbers") & """" & vbcrlf
includes=includes & "</script>" & vbcrlf

    validatetype=""
    validatetype=validatetype & "IsRequired"
    if validatetype<>"" then 
'       bodyonload=bodyonload & "define('value_sectorID','" & validatetype & "','Sector Name');"
        bodyonload=bodyonload & "define('value_sectorID','" & validatetype & "','" & jsreplace("Sector Name") & "');"
    end if
    validatetype=""
    validatetype=validatetype & "IsRequired"
    if validatetype<>"" then 
'       bodyonload=bodyonload & "define('value_Staff_Name','" & validatetype & "','Staff Name');"
        bodyonload=bodyonload & "define('value_Staff_Name','" & validatetype & "','" & jsreplace("Staff Name") & "');"
    end if

onsubmit="if (document.forms.editform.value1_passowrd && document.forms.editform.value_passowrd.value != document.forms.editform.value1_passowrd.value) {alert('" & "Passwords do not match. Re-enter password" & "');document.forms.editform.value1_passowrd.value='';return false;}"

if bodyonload<>"" then
    onsubmit=onsubmit & "return validate();"
'   bodyonload="onload=""" & bodyonload & """"
end if

    includes=includes & "<script language=""JavaScript"" src=""include/jquery.js""></script>" & vbcrlf
if useAJAX then
    includes=includes & "<script language=""JavaScript"" src=""include/ajaxsuggest.js""></script>" & vbcrlf
end if
includes=includes & "<script language=""JavaScript"" src=""include/jsfunctions.js""></script> " & vbcrlf
includes=includes & "<script language=""JavaScript""> " & vbcrlf
includes=includes & "var locale_dateformat = " & locale_info("LOCALE_IDATE") & "; " & vbcrlf
includes=includes & "var locale_datedelimiter = """ & locale_info("LOCALE_SDATE") & """; " & vbcrlf
includes=includes & "var bLoading=false; " & vbcrlf
includes=includes & "var TEXT_PLEASE_SELECT='" & addslashes("Please select") & "'; " & vbcrlf
if useAJAX then
    includes=includes & "var AUTOCOMPLETE_TABLE='Staff_Details_autocomplete.asp';" & vbcrlf
    includes=includes & "var SUGGEST_LOOKUP_TABLE='Staff_Details_lookupsuggest.asp';" & vbcrlf
end if
includes=includes & "</script> " & vbcrlf
if useAJAX then
    includes=includes & "<div id=""search_suggest""></div>" & vbcrlf
end if






xt.assign "bodyonload",bodyonload
if len(onsubmit)>0 then onsubmit="onSubmit=""" & onsubmit & """"

'// assign values to the controls

if values.Count=0 then
end if


set control_username=CreateObject("Scripting.Dictionary")
control_username("func")="xt_buildeditcontrol"
set control_username("params") = CreateObject("Scripting.Dictionary")
control_username("params")("field")="username"
control_username("params")("value")=values("username")
control_username("params")("mode")="add"
xt.assign "username_editcontrol",control_username
xt.assign "username_fieldblock",true
set control_Email=CreateObject("Scripting.Dictionary")
control_Email("func")="xt_buildeditcontrol"
set control_Email("params") = CreateObject("Scripting.Dictionary")
control_Email("params")("field")="Email"
control_Email("params")("value")=values("Email")
control_Email("params")("mode")="add"
xt.assign "Email_editcontrol",control_Email
xt.assign "Email_fieldblock",true
set control_sectorID=CreateObject("Scripting.Dictionary")
control_sectorID("func")="xt_buildeditcontrol"
set control_sectorID("params") = CreateObject("Scripting.Dictionary")
control_sectorID("params")("field")="sectorID"
control_sectorID("params")("value")=values("sectorID")
control_sectorID("params")("mode")="add"
xt.assign "sectorID_editcontrol",control_sectorID
xt.assign "sectorID_fieldblock",true
set control_Staff_Name=CreateObject("Scripting.Dictionary")
control_Staff_Name("func")="xt_buildeditcontrol"
set control_Staff_Name("params") = CreateObject("Scripting.Dictionary")
control_Staff_Name("params")("field")="Staff_Name"
control_Staff_Name("params")("value")=values("Staff_Name")
control_Staff_Name("params")("mode")="add"
xt.assign "Staff_Name_editcontrol",control_Staff_Name
xt.assign "Staff_Name_fieldblock",true
set control_Extension=CreateObject("Scripting.Dictionary")
control_Extension("func")="xt_buildeditcontrol"
set control_Extension("params") = CreateObject("Scripting.Dictionary")
control_Extension("params")("field")="Extension"
control_Extension("params")("value")=values("Extension")
control_Extension("params")("mode")="add"
xt.assign "Extension_editcontrol",control_Extension
xt.assign "Extension_fieldblock",true
set control_Mobile_Number=CreateObject("Scripting.Dictionary")
control_Mobile_Number("func")="xt_buildeditcontrol"
set control_Mobile_Number("params") = CreateObject("Scripting.Dictionary")
control_Mobile_Number("params")("field")="Mobile_Number"
control_Mobile_Number("params")("value")=values("Mobile_Number")
control_Mobile_Number("params")("mode")="add"
xt.assign "Mobile_Number_editcontrol",control_Mobile_Number
xt.assign "Mobile_Number_fieldblock",true
set control_Land_Line_Number=CreateObject("Scripting.Dictionary")
control_Land_Line_Number("func")="xt_buildeditcontrol"
set control_Land_Line_Number("params") = CreateObject("Scripting.Dictionary")
control_Land_Line_Number("params")("field")="Land_Line_Number"
control_Land_Line_Number("params")("value")=values("Land_Line_Number")
control_Land_Line_Number("params")("mode")="add"
xt.assign "Land_Line_Number_editcontrol",control_Land_Line_Number
xt.assign "Land_Line_Number_fieldblock",true
set control_Alternative_Number=CreateObject("Scripting.Dictionary")
control_Alternative_Number("func")="xt_buildeditcontrol"
set control_Alternative_Number("params") = CreateObject("Scripting.Dictionary")
control_Alternative_Number("params")("field")="Alternative_Number"
control_Alternative_Number("params")("value")=values("Alternative_Number")
control_Alternative_Number("params")("mode")="add"
xt.assign "Alternative_Number_editcontrol",control_Alternative_Number
xt.assign "Alternative_Number_fieldblock",true
set control_Other_Email_Address=CreateObject("Scripting.Dictionary")
control_Other_Email_Address("func")="xt_buildeditcontrol"
set control_Other_Email_Address("params") = CreateObject("Scripting.Dictionary")
control_Other_Email_Address("params")("field")="Other_Email_Address"
control_Other_Email_Address("params")("value")=values("Other_Email_Address")
control_Other_Email_Address("params")("mode")="add"
xt.assign "Other_Email_Address_editcontrol",control_Other_Email_Address
xt.assign "Other_Email_Address_fieldblock",true
set control_Location=CreateObject("Scripting.Dictionary")
control_Location("func")="xt_buildeditcontrol"
set control_Location("params") = CreateObject("Scripting.Dictionary")
control_Location("params")("field")="Location"
control_Location("params")("value")=values("Location")
control_Location("params")("mode")="add"
xt.assign "Location_editcontrol",control_Location
xt.assign "Location_fieldblock",true
set control_Residential_Area=CreateObject("Scripting.Dictionary")
control_Residential_Area("func")="xt_buildeditcontrol"
set control_Residential_Area("params") = CreateObject("Scripting.Dictionary")
control_Residential_Area("params")("field")="Residential_Area"
control_Residential_Area("params")("value")=values("Residential_Area")
control_Residential_Area("params")("mode")="add"
xt.assign "Residential_Area_editcontrol",control_Residential_Area
xt.assign "Residential_Area_fieldblock",true
set control_Closest__Police_Sation=CreateObject("Scripting.Dictionary")
control_Closest__Police_Sation("func")="xt_buildeditcontrol"
set control_Closest__Police_Sation("params") = CreateObject("Scripting.Dictionary")
control_Closest__Police_Sation("params")("field")="Closest_ Police_Sation"
control_Closest__Police_Sation("params")("value")=values("Closest_ Police_Sation")
control_Closest__Police_Sation("params")("mode")="add"
xt.assign "Closest__Police_Sation_editcontrol",control_Closest__Police_Sation
xt.assign "Closest__Police_Sation_fieldblock",true

xt.assign "password_attrs","name=""value_passowrd"" value=""" & my_htmlspecialchars(values("passowrd")) & """"
xt.assign "confirm_attrs","name=""value1_passowrd"" value="""& my_htmlspecialchars(values("passowrd")) & """"
xt.assign "password_block",true
xt.assign "confirm_block",true
xt.assign "username_block",true
xt.assign "buttons_block",true

Set readonlyfields = CreateObject("Scripting.Dictionary")

'// show readonly fields

linkdata=""

linkdata=linkdata & "<script language=""Javascript"">"
if useAJAX then
        output = loadSelectContent("Residential_Area",values("sectorID"),values("Residential_Area"))
        txt = ""
        for i=0 to UBound(output)
            txt = txt & jsreplace(output(i)) & "\n"
        next
        linkdata = linkdata & "preloadSelectContent(""" & txt & """, ""value_Residential_Area"", """ & jsreplace(values("Residential_Area")) &_
 """, """ & record_id & """);" & vbCrLf 
else
    '   Residential_Area - sectorID
        linkdata=linkdata & "bLoading = true;"
        linkdata=linkdata & "SetSelection('value_sectorID', 'value_Residential_Area', '" & jsreplace(values("sectorID")) & "', '" & jsreplace(values("Residential_Area")) & "', arr_Residential_Area);"
        linkdata=linkdata & "bLoading = false;"
end if

linkdata=""
linkdata=linkdata & "</script>"

if useAJAX then
    linkdata = linkdata & "<script type=""text/javascript"">" & vbCrLf
    linkdata = linkdata & "$(document).ready(function(){ " & vbCrLf
    linkdata = linkdata & "function loadSelectContent(txt, selectControl, selectValue) {" & vbCrLf
    linkdata = linkdata & "$(""#""+selectControl).get(0).options[0]=new Option(TEXT_PLEASE_SELECT,"""");" & vbCrLf
    linkdata = linkdata & "var str = txt.split(""\n"")" & vbCrLf
    linkdata = linkdata & "var index = 0;" & vbCrLf
    linkdata = linkdata & "for(i=0,j=0; i < str.length - 1; i=i+2, j++) {" & vbCrLf
    linkdata = linkdata & "$(""#""+selectControl).get(0).options[j+1]=new Option(unescape(str[i+1]),unescape(str[i]));" & vbCrLf
    linkdata = linkdata & "if ( unescape(str[i]) == selectValue ) {index = j+1;} " & vbCrLf
    linkdata = linkdata & "}" & vbCrLf
    linkdata = linkdata & "$(""#""+selectControl).get(0).selectedIndex = index; "
    linkdata = linkdata & "if(index==0 && j==1)"
    linkdata = linkdata & "$('#'+selectControl).get(0).selectedIndex = 1;"
    linkdata = linkdata & "}" & vbCrLf

        linkdata = linkdata & "$(""#value_sectorID"").change(function() {" & vbCrLf
        linkdata = linkdata & "$.get(AUTOCOMPLETE_TABLE, " & vbCrLf
        linkdata = linkdata & "{" & vbCrLf 
        linkdata = linkdata & "field: myEncode(""Residential_Area"")," & vbCrLf
        linkdata = linkdata & "value: myEncode($(""#value_sectorID"").val())" & vbCrLf
        linkdata = linkdata & "}," & vbCrLf
        linkdata = linkdata & "function(txt){" & vbCrLf
        linkdata = linkdata & "$(""#value_Residential_Area"").html(""<option value=\""\"">""+TEXT_PLEASE_SELECT+""</option>"");" & vbCrLf
        linkdata = linkdata & "var str = txt.split(""\n"");" & vbCrLf
        linkdata = linkdata & "var index = 0;" & vbCrLf
        linkdata = linkdata & "for(i=0,j=0; i < str.length - 1; i=i+2,j++) {" & vbCrLf
        linkdata = linkdata & "$(""#value_Residential_Area"").get(0).options[j+1]=new Option(unescape(str[i+1]),unescape(str[i]));" & vbCrLf
        linkdata = linkdata & "}" & vbCrLf
        linkdata = linkdata & "$(""#value_Residential_Area"").get(0).selectedIndex = 0;" & vbCrLf
        linkdata = linkdata & "if ( j == 1 ) { $(""#value_Residential_Area"").get(0).selectedIndex = 1; }" & vbCrLf
        linkdata = linkdata & "$(""#value_Residential_Area"").change();" & vbCrLf
        linkdata = linkdata & "});" & vbCrLf            
        linkdata = linkdata & "});" & vbCrLf

        output = loadSelectContent("Residential_Area",values("sectorID"),"")
        txt = ""
        for i=0 to UBound(output)
            txt = txt & output(i) & "\n"
        next
        linkdata = linkdata & "loadSelectContent(""" & txt & """, ""value_Residential_Area"", """ & jsreplace(values("Residential_Area")) &_
 """);" & vbCrLf

    linkdata = linkdata & "});" & vbCrLf
    linkdata = linkdata & "</script>" & vbCrLf
else 
    '   Residential_Area - sectorID
        linkdata=linkdata & "<script language=""Javascript"">"
        linkdata=linkdata & "bLoading = true;"
        linkdata=linkdata & "SetSelection('value_sectorID', 'value_Residential_Area', '" & jsreplace(values("sectorID")) & "', '" & jsreplace(values("Residential_Area")) & "', arr_Residential_Area);"
        linkdata=linkdata & "bLoading = false;"
        linkdata=linkdata & "</script>"
end if


'xt.assign "submit_attrs","onclick=""javascript: if (document.forms.editform.value1_passowrd==undefined) return true; if(document.forms.editform.value_passowrd.value != document.forms.editform.value1_passowrd.value) {alert('" & "Passwords do not match. Re-enter password" & "');document.forms.editform.value1_passowrd.value='';return false;} return true;"""

set body=CreateObject("Scripting.Dictionary")
body("begin")=includes
body("begin")=body("begin") & "<form encType=""multipart/form-data"" method=""POST"" action=""register.asp"" name=""editform"" " & onsubmit & ">"
body("begin")=body("begin") & "<input type=hidden name=btnSubmit value=""Register"">"
body("end")="</form>" & linkdata & "<script>" & bodyonload & "</script>"
xt.assign "body",body

set keys = CreateObject("Scripting.Dictionary")

'
'   keys("StaffID")=""
'

templatefile = "register.htm"
DoEvent "BeforeShowRegister xt,templatefile"
xt.display(templatefile)



%><!-- InstanceEndEditable --></td>
        </tr>
      <tr>
        <td bgcolor="#DFEAF5">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>

This the whole code in the registration page.......

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Warden_system_default.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="1" bordercolor="#FFFFFF">
      <tr>
        <td height="133" bgcolor="#DFEAF5"><img src="images/warden-headertextgif.gif" alt="WARDEN SYSTEM" width="770" height="133" />          </td>
      </tr>
      <tr>
        <td height="10" background="login.asp" bgcolor="#FFFFFF"><p></td>
      </tr>
      <tr valign="top">
        <td bgcolor="#FFFFFF"><div id="tables_block">
  <!-- InstanceBeginEditable name="content" --><!--#include file="include/dbcommon.asp"-->
<!--#include file="include/Staff_Details_variables.asp"-->
<!--#include file="include/md5.asp"-->
<!--#include file="libs/xtempl.asp"-->
<%
dim xt
set xt = new XTempl

    Set myRequest = CreateObject("Scripting.Dictionary")
    Set myRequestFiles = CreateObject("Scripting.Dictionary")
    if ParseMultiPartForm()=true then parse=1

registered=false
onload=" "
Message=""
Username=""
Password=""
Email=""


set values = CreateObject("Scripting.Dictionary")
dbConnection=""
db_connect()

DoEvent "BeforeProcessRegister dbConnection"




if getrequestform("btnSubmit") = "Register" then


    Set rs = server.CreateObject("ADODB.Recordset")

    set filename_values = CreateObject("Scripting.Dictionary")


'// processing username - start

    value = postvalue("value_username")
    ttype=postvalue("type_username")
    toadd=true
if myRequest.Exists("value_username") or myRequest.Exists("value_username[]") or myRequest.Exists("type_username") then
            value=prepare_for_db("username",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("username") = value
        end if
    end if
'// processibng username - end

'// processing passowrd - start

    value = postvalue("value_passowrd")
    ttype=postvalue("type_passowrd")
    toadd=true
if myRequest.Exists("value_passowrd") or myRequest.Exists("value_passowrd[]") or myRequest.Exists("type_passowrd") then
            value=prepare_for_db("passowrd",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("passowrd") = value
        end if
    end if
'// processibng passowrd - end

'// processing Email - start

    value = postvalue("value_Email")
    ttype=postvalue("type_Email")
    toadd=true
if myRequest.Exists("value_Email") or myRequest.Exists("value_Email[]") or myRequest.Exists("type_Email") then
            value=prepare_for_db("Email",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Email") = value
        end if
    end if
'// processibng Email - end

'// processing sectorID - start

    value = postvalue("value_sectorID")
    ttype=postvalue("type_sectorID")
    toadd=true
if myRequest.Exists("value_sectorID") or myRequest.Exists("value_sectorID[]") or myRequest.Exists("type_sectorID") then
            value=prepare_for_db("sectorID",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("sectorID") = value
        end if
    end if
'// processibng sectorID - end

'// processing Staff_Name - start

    value = postvalue("value_Staff_Name")
    ttype=postvalue("type_Staff_Name")
    toadd=true
if myRequest.Exists("value_Staff_Name") or myRequest.Exists("value_Staff_Name[]") or myRequest.Exists("type_Staff_Name") then
            value=prepare_for_db("Staff_Name",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Staff_Name") = value
        end if
    end if
'// processibng Staff_Name - end

'// processing Extension - start

    value = postvalue("value_Extension")
    ttype=postvalue("type_Extension")
    toadd=true
if myRequest.Exists("value_Extension") or myRequest.Exists("value_Extension[]") or myRequest.Exists("type_Extension") then
            value=prepare_for_db("Extension",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Extension") = value
        end if
    end if
'// processibng Extension - end

'// processing Mobile_Number - start

    value = postvalue("value_Mobile_Number")
    ttype=postvalue("type_Mobile_Number")
    toadd=true
if myRequest.Exists("value_Mobile_Number") or myRequest.Exists("value_Mobile_Number[]") or myRequest.Exists("type_Mobile_Number") then
            value=prepare_for_db("Mobile_Number",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Mobile_Number") = value
        end if
    end if
'// processibng Mobile_Number - end

'// processing Land_Line_Number - start

    value = postvalue("value_Land_Line_Number")
    ttype=postvalue("type_Land_Line_Number")
    toadd=true
if myRequest.Exists("value_Land_Line_Number") or myRequest.Exists("value_Land_Line_Number[]") or myRequest.Exists("type_Land_Line_Number") then
            value=prepare_for_db("Land_Line_Number",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Land_Line_Number") = value
        end if
    end if
'// processibng Land_Line_Number - end

'// processing Alternative_Number - start

    value = postvalue("value_Alternative_Number")
    ttype=postvalue("type_Alternative_Number")
    toadd=true
if myRequest.Exists("value_Alternative_Number") or myRequest.Exists("value_Alternative_Number[]") or myRequest.Exists("type_Alternative_Number") then
            value=prepare_for_db("Alternative_Number",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Alternative_Number") = value
        end if
    end if
'// processibng Alternative_Number - end

'// processing Other_Email_Address - start

    value = postvalue("value_Other_Email_Address")
    ttype=postvalue("type_Other_Email_Address")
    toadd=true
if myRequest.Exists("value_Other_Email_Address") or myRequest.Exists("value_Other_Email_Address[]") or myRequest.Exists("type_Other_Email_Address") then
            value=prepare_for_db("Other_Email_Address",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Other_Email_Address") = value
        end if
    end if
'// processibng Other_Email_Address - end

'// processing Location - start

    value = postvalue("value_Location")
    ttype=postvalue("type_Location")
    toadd=true
if myRequest.Exists("value_Location") or myRequest.Exists("value_Location[]") or myRequest.Exists("type_Location") then
            value=prepare_for_db("Location",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Location") = value
        end if
    end if
'// processibng Location - end

'// processing Residential_Area - start

    value = postvalue("value_Residential_Area")
    ttype=postvalue("type_Residential_Area")
    toadd=true
if myRequest.Exists("value_Residential_Area") or myRequest.Exists("value_Residential_Area[]") or myRequest.Exists("type_Residential_Area") then
            value=prepare_for_db("Residential_Area",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Residential_Area") = value
        end if
    end if
'// processibng Residential_Area - end

'// processing Closest_ Police_Sation - start

    value = postvalue("value_Closest__Police_Sation")
    ttype=postvalue("type_Closest__Police_Sation")
    toadd=true
if myRequest.Exists("value_Closest__Police_Sation") or myRequest.Exists("value_Closest__Police_Sation[]") or myRequest.Exists("type_Closest__Police_Sation") then
            value=prepare_for_db("Closest_ Police_Sation",value,ttype,"")
        if vartype(value)=11 then 
            if value=false then toadd=false
        end if
        if toadd then
            values("Closest_ Police_Sation") = value
        end if
    end if
'// processibng Closest_ Police_Sation - end


Username = postvalue("value_username")
Password = postvalue("value_passowrd")

    Email = values.Item("Email")

'// add filenames to values
    for each key in filename_values
        values(key)=filename_values.Item(key)
    next

'   check if entered username already exists
    if len(Username)=0 then 
        if Message<>"" then Message=Message & "<br>"
        Message=Message & "Username can not be empty."
    else
        strSQL="select count(*) from [Staff Details] where [username]=" & add_db_quotes("username",Username)
        rs.Open strSQL,dbConnection
        if not rs.EOF then
            if CLng(rs(0))>0 then
                Message="Username" & " <i>" & Username & "</i> " & "already exists. Choose another username."
            end if
        end if
        rs.close
    end if


'// check if entered email already exists

    if len(Email)=0 then 
        if Message<>"" then Message=Message & "<br>"
        Message=Message & "Please enter valid email address."
    else
        strSQL="select count(*) from [Staff Details] where [Email]=" & add_db_quotes("Email", Email)
        rs.Open strSQL,dbConnection
        if not rs.EOF then
            if CLng(rs(0))>0 then
                if Message<>"" then Message=Message & "<br>"
                Message=Message & "Email" & " <i>" & Email & "</i> " & "already registered. If you forgot your username or password use the password reminder form."
            end if
        end if
        rs.close
    end if

    if not checkpassword(values("passowrd")) then
        if Message<>"" then Message=Message & "<br>"
        dim fmt
        fmt="Password must be at least %% characters length."
        fmt=replace(fmt,"%%","5")
        Message = Message & "<br>" & fmt
    end if


    retval=true
    if Message="" then DoEvent "retval = BeforeRegister(values)"

    if Message="" and  retval then

'   //  encrypt password
    originalpassword=values.Item("passowrd")
    values.Item("passowrd") = md5(values.Item("passowrd"))

' insert new user

    rs.Open "select * from [Staff Details] where 1=0", dbConnection, 1,2
    rs.Addnew
'   insert StaffID field
    strValue=false
    if values.exists("StaffID") then    _
        strValue = values.Item("StaffID")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_StaffID")
                                if strValue<>"" and IsNumeric(strValue) then 
            rs("StaffID") = CLng(strValue)
        else
            rs("StaffID") = null
        end if
    end if
'   insert Staff_Name field
    strValue=false
    if values.exists("Staff_Name") then     _
        strValue = values.Item("Staff_Name")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Staff_Name")
                                rs("Staff_Name") = strValue                 
    end if
'   insert Email field
    strValue=false
    if values.exists("Email") then  _
        strValue = values.Item("Email")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Email")
                                rs("Email") = strValue                  
    end if
'   insert Extension field
    strValue=false
    if values.exists("Extension") then  _
        strValue = values.Item("Extension")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Extension")
                                rs("Extension") = strValue                  
    end if
'   insert Mobile_Number field
    strValue=false
    if values.exists("Mobile_Number") then  _
        strValue = values.Item("Mobile_Number")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Mobile_Number")
                                rs("Mobile_Number") = strValue                  
    end if
'   insert Land_Line_Number field
    strValue=false
    if values.exists("Land_Line_Number") then   _
        strValue = values.Item("Land_Line_Number")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Land_Line_Number")
                                rs("Land_Line_Number") = strValue                   
    end if
'   insert Alternative_Number field
    strValue=false
    if values.exists("Alternative_Number") then     _
        strValue = values.Item("Alternative_Number")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Alternative_Number")
                                rs("Alternative_Number") = strValue                 
    end if
'   insert Other_Email_Address field
    strValue=false
    if values.exists("Other_Email_Address") then    _
        strValue = values.Item("Other_Email_Address")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Other_Email_Address")
                                rs("Other_Email_Address") = strValue                    
    end if
'   insert Location field
    strValue=false
    if values.exists("Location") then   _
        strValue = values.Item("Location")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Location")
                                rs("Location") = strValue                   
    end if
'   insert Residential_Area field
    strValue=false
    if values.exists("Residential_Area") then   _
        strValue = values.Item("Residential_Area")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Residential_Area")
                                rs("Residential_Area") = strValue                   
    end if
'   insert WardenID field
    strValue=false
    if values.exists("WardenID") then   _
        strValue = values.Item("WardenID")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_WardenID")
                                if strValue<>"" and IsNumeric(strValue) then 
            rs("WardenID") = CLng(strValue)
        else
            rs("WardenID") = null
        end if
    end if
'   insert Closest_ Police_Sation field
    strValue=false
    if values.exists("Closest_ Police_Sation") then     _
        strValue = values.Item("Closest_ Police_Sation")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_Closest__Police_Sation")
                                rs("Closest_ Police_Sation") = strValue                 
    end if
'   insert username field
    strValue=false
    if values.exists("username") then   _
        strValue = values.Item("username")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_username")
                                rs("username") = strValue                   
    end if
'   insert passowrd field
    strValue=false
    if values.exists("passowrd") then   _
        strValue = values.Item("passowrd")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_passowrd")
                                rs("passowrd") = strValue                   
    end if
'   insert sectorID field
    strValue=false
    if values.exists("sectorID") then   _
        strValue = values.Item("sectorID")
    if not errorhappened and not (vartype(strValue)=11 and strValue=False) then
        if isnull(strValue) then strValue=""
        ctype = GetRequestForm("type_sectorID")
                                if strValue<>"" and IsNumeric(strValue) then 
            rs("sectorID") = CLng(strValue)
        else
            rs("sectorID") = null
        end if
    end if
    rs.Update

    values.Item("passowrd")=originalpassword
        DoEvent "AfterSuccessfulRegistration values"

        url = "http://" & request.ServerVariables("SERVER_NAME")
        if CStr(request.ServerVariables("SERVER_PORT"))<>"80" then _
            url = url & ":" & request.ServerVariables("SERVER_PORT")
        url= url & request.ServerVariables("SCRIPT_NAME")
'// send email to user
        message="You have registered as user at" & " " & url & vbcrlf
'       strLabel = "Username"
        strLabel = "Username"
        message=message & strLabel & ": " & values.Item("username") & vbcrlf
'       strLabel = "Passowrd"
        strLabel = "Passowrd"
        message=message & strLabel & ": " & values.Item("passowrd") & vbcrlf
'       strLabel = "Email"
        strLabel = "Email"
        message=message & strLabel & ": " & values.Item("Email") & vbcrlf
'       strLabel = "Sector Name"
        strLabel = "Sector Name"
        message=message & strLabel & ": " & values.Item("sectorID") & vbcrlf
'       strLabel = "Staff Name"
        strLabel = "Staff Name"
        message=message & strLabel & ": " & values.Item("Staff_Name") & vbcrlf
'       strLabel = "Extension"
        strLabel = "Extension"
        message=message & strLabel & ": " & values.Item("Extension") & vbcrlf
'       strLabel = "Mobile Number"
        strLabel = "Mobile Number"
        message=message & strLabel & ": " & values.Item("Mobile_Number") & vbcrlf
'       strLabel = "Land Line Number"
        strLabel = "Land Line Number"
        message=message & strLabel & ": " & values.Item("Land_Line_Number") & vbcrlf
'       strLabel = "Alternative Number"
        strLabel = "Alternative Number"
        message=message & strLabel & ": " & values.Item("Alternative_Number") & vbcrlf
'       strLabel = "Other Email Address"
        strLabel = "Other Email Address"
        message=message & strLabel & ": " & values.Item("Other_Email_Address") & vbcrlf
'       strLabel = "Location (Street, Number)"
        strLabel = "Location (Street, Number)"
        message=message & strLabel & ": " & values.Item("Location") & vbcrlf
'       strLabel = "Residential Area"
        strLabel = "Residential Area"
        message=message & strLabel & ": " & values.Item("Residential_Area") & vbcrlf
'       strLabel = "Closest Police Sation"
        strLabel = "Closest Police Sation"
        message=message & strLabel & ": " & values.Item("Closest_ Police_Sation") & vbcrlf
        Call sendmail(Email,"Notification on registering",message)

'// send letter to admin
        message="User registered at" & " " & url & vbcrlf
'       strLabel = "Username"
        strLabel = "Username"
        message=message & strLabel & ": " & values.Item("username") & vbcrlf
'       strLabel = "Email"
        strLabel = "Email"
        message=message & strLabel & ": " & values.Item("Email") & vbcrlf
'       strLabel = "Sector Name"
        strLabel = "Sector Name"
        message=message & strLabel & ": " & values.Item("sectorID") & vbcrlf
'       strLabel = "Staff Name"
        strLabel = "Staff Name"
        message=message & strLabel & ": " & values.Item("Staff_Name") & vbcrlf
'       strLabel = "Extension"
        strLabel = "Extension"
        message=message & strLabel & ": " & values.Item("Extension") & vbcrlf
'       strLabel = "Mobile Number"
        strLabel = "Mobile Number"
        message=message & strLabel & ": " & values.Item("Mobile_Number") & vbcrlf
'       strLabel = "Land Line Number"
        strLabel = "Land Line Number"
        message=message & strLabel & ": " & values.Item("Land_Line_Number") & vbcrlf
'       strLabel = "Alternative Number"
        strLabel = "Alternative Number"
        message=message & strLabel & ": " & values.Item("Alternative_Number") & vbcrlf
'       strLabel = "Other Email Address"
        strLabel = "Other Email Address"
        message=message & strLabel & ": " & values.Item("Other_Email_Address") & vbcrlf
'       strLabel = "Location (Street, Number)"
        strLabel = "Location (Street, Number)"
        message=message & strLabel & ": " & values.Item("Location") & vbcrlf
'       strLabel = "Residential Area"
        strLabel = "Residential Area"
        message=message & strLabel & ": " & values.Item("Residential_Area") & vbcrlf
'       strLabel = "Closest Police Sation"
        strLabel = "Closest Police Sation"
        message=message & strLabel & ": " & values.Item("Closest_ Police_Sation") & vbcrlf
        Call sendmail("erick.otieno@unhabitat.org","Notification on registering",message)



'// show Registartion successful message

        set body=CreateObject("Scripting.Dictionary")
        body("begin")="<form method=""POST"" action=""login.asp"" name=""loginform"">"
        body("begin")=body("begin") & "<input type=""Hidden"" name=username value=""" & my_htmlspecialchars(Username) & """>"
        body("begin")=body("begin") & "<input type=""Hidden"" name=password value=""" & my_htmlspecialchars(Password) & """>"
        body("begin")=body("begin") & "</form>"
        xt.assign "registered_block",true
        xt.assign "body",body
        xt.assign "loginlink_attrs","onclick=""document.forms.loginform.submit();return false;"""
        xt.display("register_success.htm")
        response.End
    else
        DoEvent "AfterUnsuccessfulRegistration values"
    end if

    if message<>"" then
        xt.assign "message",message
        xt.assign "message_block",true
        end if
end if

'//send to warden in sector1


'// validation stuff
bodyonload=""
onsubmit=""
includes=""

includes=includes & "<script language=""JavaScript"" src=""include/validate.js""></script>" & vbcrlf
includes=includes & "<script language=""JavaScript"">" & vbcrlf
includes=includes & "var TEXT_FIELDS_REQUIRED=""" & addslashes("The Following fields are Required") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_ZIPCODES=""" & addslashes("") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_EMAILS=""" & addslashes("The Following fields must be valid Emails") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_NUMBERS=""" & addslashes("The Following fields must be Numbers") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_CURRENCY=""" & addslashes("The Following fields must be currency") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_PHONE=""" & addslashes("The Following fields must be Phone Numbers") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_PASSWORD1=""" & addslashes("The Following fields must be valid Passwords") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_PASSWORD2=""" & addslashes("should be at least 4 characters long") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_PASSWORD3=""" & addslashes("Cannot be 'password'") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_STATE=""" & addslashes("The Following fields must be State Names") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_SSN=""" & addslashes("The Following fields must be Social Security Numbers") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_DATE=""" & addslashes("The Following fields must be valid dates") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_TIME=""" & addslashes("The Following fields must be valid time in 24-hours format") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_CC=""" & addslashes("The Following fields must be valid Credit Card Numbers") & """" & vbcrlf
includes=includes & "var TEXT_FIELDS_SSN=""" & addslashes("The Following fields must be Social Security Numbers") & """" & vbcrlf
includes=includes & "</script>" & vbcrlf

    validatetype=""
    validatetype=validatetype & "IsRequired"
    if validatetype<>"" then 
'       bodyonload=bodyonload & "define('value_sectorID','" & validatetype & "','Sector Name');"
        bodyonload=bodyonload & "define('value_sectorID','" & validatetype & "','" & jsreplace("Sector Name") & "');"
    end if
    validatetype=""
    validatetype=validatetype & "IsRequired"
    if validatetype<>"" then 
'       bodyonload=bodyonload & "define('value_Staff_Name','" & validatetype & "','Staff Name');"
        bodyonload=bodyonload & "define('value_Staff_Name','" & validatetype & "','" & jsreplace("Staff Name") & "');"
    end if

onsubmit="if (document.forms.editform.value1_passowrd && document.forms.editform.value_passowrd.value != document.forms.editform.value1_passowrd.value) {alert('" & "Passwords do not match. Re-enter password" & "');document.forms.editform.value1_passowrd.value='';return false;}"

if bodyonload<>"" then
    onsubmit=onsubmit & "return validate();"
'   bodyonload="onload=""" & bodyonload & """"
end if

    includes=includes & "<script language=""JavaScript"" src=""include/jquery.js""></script>" & vbcrlf
if useAJAX then
    includes=includes & "<script language=""JavaScript"" src=""include/ajaxsuggest.js""></script>" & vbcrlf
end if
includes=includes & "<script language=""JavaScript"" src=""include/jsfunctions.js""></script> " & vbcrlf
includes=includes & "<script language=""JavaScript""> " & vbcrlf
includes=includes & "var locale_dateformat = " & locale_info("LOCALE_IDATE") & "; " & vbcrlf
includes=includes & "var locale_datedelimiter = """ & locale_info("LOCALE_SDATE") & """; " & vbcrlf
includes=includes & "var bLoading=false; " & vbcrlf
includes=includes & "var TEXT_PLEASE_SELECT='" & addslashes("Please select") & "'; " & vbcrlf
if useAJAX then
    includes=includes & "var AUTOCOMPLETE_TABLE='Staff_Details_autocomplete.asp';" & vbcrlf
    includes=includes & "var SUGGEST_LOOKUP_TABLE='Staff_Details_lookupsuggest.asp';" & vbcrlf
end if
includes=includes & "</script> " & vbcrlf
if useAJAX then
    includes=includes & "<div id=""search_suggest""></div>" & vbcrlf
end if






xt.assign "bodyonload",bodyonload
if len(onsubmit)>0 then onsubmit="onSubmit=""" & onsubmit & """"

'// assign values to the controls

if values.Count=0 then
end if


set control_username=CreateObject("Scripting.Dictionary")
control_username("func")="xt_buildeditcontrol"
set control_username("params") = CreateObject("Scripting.Dictionary")
control_username("params")("field")="username"
control_username("params")("value")=values("username")
control_username("params")("mode")="add"
xt.assign "username_editcontrol",control_username
xt.assign "username_fieldblock",true
set control_Email=CreateObject("Scripting.Dictionary")
control_Email("func")="xt_buildeditcontrol"
set control_Email("params") = CreateObject("Scripting.Dictionary")
control_Email("params")("field")="Email"
control_Email("params")("value")=values("Email")
control_Email("params")("mode")="add"
xt.assign "Email_editcontrol",control_Email
xt.assign "Email_fieldblock",true
set control_sectorID=CreateObject("Scripting.Dictionary")
control_sectorID("func")="xt_buildeditcontrol"
set control_sectorID("params") = CreateObject("Scripting.Dictionary")
control_sectorID("params")("field")="sectorID"
control_sectorID("params")("value")=values("sectorID")
control_sectorID("params")("mode")="add"
xt.assign "sectorID_editcontrol",control_sectorID
xt.assign "sectorID_fieldblock",true
set control_Staff_Name=CreateObject("Scripting.Dictionary")
control_Staff_Name("func")="xt_buildeditcontrol"
set control_Staff_Name("params") = CreateObject("Scripting.Dictionary")
control_Staff_Name("params")("field")="Staff_Name"
control_Staff_Name("params")("value")=values("Staff_Name")
control_Staff_Name("params")("mode")="add"
xt.assign "Staff_Name_editcontrol",control_Staff_Name
xt.assign "Staff_Name_fieldblock",true
set control_Extension=CreateObject("Scripting.Dictionary")
control_Extension("func")="xt_buildeditcontrol"
set control_Extension("params") = CreateObject("Scripting.Dictionary")
control_Extension("params")("field")="Extension"
control_Extension("params")("value")=values("Extension")
control_Extension("params")("mode")="add"
xt.assign "Extension_editcontrol",control_Extension
xt.assign "Extension_fieldblock",true
set control_Mobile_Number=CreateObject("Scripting.Dictionary")
control_Mobile_Number("func")="xt_buildeditcontrol"
set control_Mobile_Number("params") = CreateObject("Scripting.Dictionary")
control_Mobile_Number("params")("field")="Mobile_Number"
control_Mobile_Number("params")("value")=values("Mobile_Number")
control_Mobile_Number("params")("mode")="add"
xt.assign "Mobile_Number_editcontrol",control_Mobile_Number
xt.assign "Mobile_Number_fieldblock",true
set control_Land_Line_Number=CreateObject("Scripting.Dictionary")
control_Land_Line_Number("func")="xt_buildeditcontrol"
set control_Land_Line_Number("params") = CreateObject("Scripting.Dictionary")
control_Land_Line_Number("params")("field")="Land_Line_Number"
control_Land_Line_Number("params")("value")=values("Land_Line_Number")
control_Land_Line_Number("params")("mode")="add"
xt.assign "Land_Line_Number_editcontrol",control_Land_Line_Number
xt.assign "Land_Line_Number_fieldblock",true
set control_Alternative_Number=CreateObject("Scripting.Dictionary")
control_Alternative_Number("func")="xt_buildeditcontrol"
set control_Alternative_Number("params") = CreateObject("Scripting.Dictionary")
control_Alternative_Number("params")("field")="Alternative_Number"
control_Alternative_Number("params")("value")=values("Alternative_Number")
control_Alternative_Number("params")("mode")="add"
xt.assign "Alternative_Number_editcontrol",control_Alternative_Number
xt.assign "Alternative_Number_fieldblock",true
set control_Other_Email_Address=CreateObject("Scripting.Dictionary")
control_Other_Email_Address("func")="xt_buildeditcontrol"
set control_Other_Email_Address("params") = CreateObject("Scripting.Dictionary")
control_Other_Email_Address("params")("field")="Other_Email_Address"
control_Other_Email_Address("params")("value")=values("Other_Email_Address")
control_Other_Email_Address("params")("mode")="add"
xt.assign "Other_Email_Address_editcontrol",control_Other_Email_Address
xt.assign "Other_Email_Address_fieldblock",true
set control_Location=CreateObject("Scripting.Dictionary")
control_Location("func")="xt_buildeditcontrol"
set control_Location("params") = CreateObject("Scripting.Dictionary")
control_Location("params")("field")="Location"
control_Location("params")("value")=values("Location")
control_Location("params")("mode")="add"
xt.assign "Location_editcontrol",control_Location
xt.assign "Location_fieldblock",true
set control_Residential_Area=CreateObject("Scripting.Dictionary")
control_Residential_Area("func")="xt_buildeditcontrol"
set control_Residential_Area("params") = CreateObject("Scripting.Dictionary")
control_Residential_Area("params")("field")="Residential_Area"
control_Residential_Area("params")("value")=values("Residential_Area")
control_Residential_Area("params")("mode")="add"
xt.assign "Residential_Area_editcontrol",control_Residential_Area
xt.assign "Residential_Area_fieldblock",true
set control_Closest__Police_Sation=CreateObject("Scripting.Dictionary")
control_Closest__Police_Sation("func")="xt_buildeditcontrol"
set control_Closest__Police_Sation("params") = CreateObject("Scripting.Dictionary")
control_Closest__Police_Sation("params")("field")="Closest_ Police_Sation"
control_Closest__Police_Sation("params")("value")=values("Closest_ Police_Sation")
control_Closest__Police_Sation("params")("mode")="add"
xt.assign "Closest__Police_Sation_editcontrol",control_Closest__Police_Sation
xt.assign "Closest__Police_Sation_fieldblock",true

xt.assign "password_attrs","name=""value_passowrd"" value=""" & my_htmlspecialchars(values("passowrd")) & """"
xt.assign "confirm_attrs","name=""value1_passowrd"" value="""& my_htmlspecialchars(values("passowrd")) & """"
xt.assign "password_block",true
xt.assign "confirm_block",true
xt.assign "username_block",true
xt.assign "buttons_block",true

Set readonlyfields = CreateObject("Scripting.Dictionary")

'// show readonly fields

linkdata=""

linkdata=linkdata & "<script language=""Javascript"">"
if useAJAX then
        output = loadSelectContent("Residential_Area",values("sectorID"),values("Residential_Area"))
        txt = ""
        for i=0 to UBound(output)
            txt = txt & jsreplace(output(i)) & "n"
        next
        linkdata = linkdata & "preloadSelectContent(""" & txt & """, ""value_Residential_Area"", """ & jsreplace(values("Residential_Area")) &_
 """, """ & record_id & """);" & vbCrLf 
else
    '   Residential_Area - sectorID
        linkdata=linkdata & "bLoading = true;"
        linkdata=linkdata & "SetSelection('value_sectorID', 'value_Residential_Area', '" & jsreplace(values("sectorID")) & "', '" & jsreplace(values("Residential_Area")) & "', arr_Residential_Area);"
        linkdata=linkdata & "bLoading = false;"
end if

linkdata=""
linkdata=linkdata & "</script>"

if useAJAX then
    linkdata = linkdata & "<script type=""text/javascript"">" & vbCrLf
    linkdata = linkdata & "$(document).ready(function(){ " & vbCrLf
    linkdata = linkdata & "function loadSelectContent(txt, selectControl, selectValue) {" & vbCrLf
    linkdata = linkdata & "$(""#""+selectControl).get(0).options[0]=new Option(TEXT_PLEASE_SELECT,"""");" & vbCrLf
    linkdata = linkdata & "var str = txt.split(""n"")" & vbCrLf
    linkdata = linkdata & "var index = 0;" & vbCrLf
    linkdata = linkdata & "for(i=0,j=0; i < str.length - 1; i=i+2, j++) {" & vbCrLf
    linkdata = linkdata & "$(""#""+selectControl).get(0).options[j+1]=new Option(unescape(str[i+1]),unescape(str[i]));" & vbCrLf
    linkdata = linkdata & "if ( unescape(str[i]) == selectValue ) {index = j+1;} " & vbCrLf
    linkdata = linkdata & "}" & vbCrLf
    linkdata = linkdata & "$(""#""+selectControl).get(0).selectedIndex = index; "
    linkdata = linkdata & "if(index==0 && j==1)"
    linkdata = linkdata & "$('#'+selectControl).get(0).selectedIndex = 1;"
    linkdata = linkdata & "}" & vbCrLf

        linkdata = linkdata & "$(""#value_sectorID"").change(function() {" & vbCrLf
        linkdata = linkdata & "$.get(AUTOCOMPLETE_TABLE, " & vbCrLf
        linkdata = linkdata & "{" & vbCrLf 
        linkdata = linkdata & "field: myEncode(""Residential_Area"")," & vbCrLf
        linkdata = linkdata & "value: myEncode($(""#value_sectorID"").val())" & vbCrLf
        linkdata = linkdata & "}," & vbCrLf
        linkdata = linkdata & "function(txt){" & vbCrLf
        linkdata = linkdata & "$(""#value_Residential_Area"").html(""<option value="""">""+TEXT_PLEASE_SELECT+""</option>"");" & vbCrLf
        linkdata = linkdata & "var str = txt.split(""n"");" & vbCrLf
        linkdata = linkdata & "var index = 0;" & vbCrLf
        linkdata = linkdata & "for(i=0,j=0; i < str.length - 1; i=i+2,j++) {" & vbCrLf
        linkdata = linkdata & "$(""#value_Residential_Area"").get(0).options[j+1]=new Option(unescape(str[i+1]),unescape(str[i]));" & vbCrLf
        linkdata = linkdata & "}" & vbCrLf
        linkdata = linkdata & "$(""#value_Residential_Area"").get(0).selectedIndex = 0;" & vbCrLf
        linkdata = linkdata & "if ( j == 1 ) { $(""#value_Residential_Area"").get(0).selectedIndex = 1; }" & vbCrLf
        linkdata = linkdata & "$(""#value_Residential_Area"").change();" & vbCrLf
        linkdata = linkdata & "});" & vbCrLf            
        linkdata = linkdata & "});" & vbCrLf

        output = loadSelectContent("Residential_Area",values("sectorID"),"")
        txt = ""
        for i=0 to UBound(output)
            txt = txt & output(i) & "n"
        next
        linkdata = linkdata & "loadSelectContent(""" & txt & """, ""value_Residential_Area"", """ & jsreplace(values("Residential_Area")) &_
 """);" & vbCrLf

    linkdata = linkdata & "});" & vbCrLf
    linkdata = linkdata & "</script>" & vbCrLf
else 
    '   Residential_Area - sectorID
        linkdata=linkdata & "<script language=""Javascript"">"
        linkdata=linkdata & "bLoading = true;"
        linkdata=linkdata & "SetSelection('value_sectorID', 'value_Residential_Area', '" & jsreplace(values("sectorID")) & "', '" & jsreplace(values("Residential_Area")) & "', arr_Residential_Area);"
        linkdata=linkdata & "bLoading = false;"
        linkdata=linkdata & "</script>"
end if


'xt.assign "submit_attrs","onclick=""javascript: if (document.forms.editform.value1_passowrd==undefined) return true; if(document.forms.editform.value_passowrd.value != document.forms.editform.value1_passowrd.value) {alert('" & "Passwords do not match. Re-enter password" & "');document.forms.editform.value1_passowrd.value='';return false;} return true;"""

set body=CreateObject("Scripting.Dictionary")
body("begin")=includes
body("begin")=body("begin") & "<form encType=""multipart/form-data"" method=""POST"" action=""register.asp"" name=""editform"" " & onsubmit & ">"
body("begin")=body("begin") & "<input type=hidden name=btnSubmit value=""Register"">"
body("end")="</form>" & linkdata & "<script>" & bodyonload & "</script>"
xt.assign "body",body

set keys = CreateObject("Scripting.Dictionary")

'
'   keys("StaffID")=""
'

templatefile = "register.htm"
DoEvent "BeforeShowRegister xt,templatefile"
xt.display(templatefile)



%><!-- InstanceEndEditable --></td>
        </tr>
      <tr>
        <td bgcolor="#DFEAF5"> </td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
<!-- InstanceEnd --></html>
select case SectionID
	case "1"
		option_email= "name1@site.com" 	
	case "2"
	        option_email= "name2@site.com" 
	case else	
                option_email= "name3@site.com" 
end select

      Call sendmail("option_email","Notification on registering",message)

Thanks a lot.... I will try it and let you know the outcome...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.