Asp Validation for login and registration (High importance and priority) respond fast

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • satishknight
    New Member
    • Jan 2008
    • 4

    Asp Validation for login and registration (High importance and priority) respond fast

    Hi,

    Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it has to tell then them its wrong information but currently it takes then to a next page and then tells them its incorrect information. This is tedious as every time they enter wrong they will be redirected to a different page and then they have to come back and they try again it’s the same for registration. Pls do help i appreciate the quick help.....

    Login validation code below:- (below the error. asp is the page where it gets directed and this page displays only stating the information is incorrect and no other information)

    <%
    YourIP = Request.ServerV ariables("Remot e_Host")
    function validate(input)
    bad_strings = array("'", "select", "union", "insert", "--")
    for each i in bad_strings
    if ( inStr(input, i) <> 0) then
    validate = false
    exit function
    end if
    next
    validate = true
    end function
    LoginID = Trim(Request("L oginID"))
    Password = Trim(Request("P assword"))

    If Len(LoginID) < 1 Or Len(Password) < 1 Then
    response.redire ct("Error.asp?O K=InValid Login ID / Password")
    End If

    If (not validate(LoginI D) or not validate(Passwo rd)) then
    response.redire ct("Error.asp?O K=Invalid Email ID / Password")
    end if

    '------------- Login-----------------
    AID = LoginID
    If Len(AID) > 1 and (Session("JLogg edIn")) = "" Then
    Session("JLogge dIn") = AID
    %>
    <!--#include file="datacon.a sp"-->
    <%
    Set Conn = Server.CreateOb ject ("ADODB.Connect ion")
    Conn.Open xDb_Conn_Str
    Set sql = Conn.Execute("S ELECT * FROM Seeker where EmailID = '"& AID &"' AND Password = '"& Password &"'")
    If sql.EOF Then
    Session("JLogge dIn") = ""
    SUL = server.urlencod e("InValid Login ID / Password")
    Response.Redire ct("Error.asp?O K=" & SUL)
    else
    Session("JLogge dIn") = "true"
    Session("JLogin ID") = LoginID
    Response.Redire ct("JobSeekers. asp")
    End If
    Conn.close
    set Conn = nothing
    End If
    '---------------------End Of Login--------------
    If session("JLogge dIn") = "true" then response.redire ct "jobseekers.asp "
    %>

    What i want is it show validate and then say in the same login page that the information for login is incorrect.



    +============== =============== =============== ====+

    2) For registration window: It has the same problem for ex:- there are many fiels like name phone number and other. if any one is incorrect when we hit submit button if the data is wrong then it goes to error.asp and then only displays whats the error. Actually i want it to display in the same registration page itself that the information is incorrect may be a pop up or just a information on the same page.

    Registration page Code details:-

    +============== =============== ==============+

    <%
    '-------------Validate Input for possible mischief
    function validate(input)
    bad_strings = array("'", "select", "union", "insert", "--")
    for each i in bad_strings
    if ( inStr(input, i) <> 0) then
    validate = false
    exit function
    end if
    next
    validate = true
    end function
    CNT = 0
    '-----------------Get the Form Details
    LoginID = Trim (Request("Login ID"))
    If Len(LoginID) > 0 Then
    If Len(LoginID) > 50 or Len(LoginID) < 4 Then
    WLID = "In Valid Login ID : "
    CNT = 5
    End If
    If (not validate(LoginI D)) then
    WLID = "In Valid Login ID : "
    CNT = 5
    end if
    Password = Trim (Request("Passw ord"))
    If Len(Password) > 20 or Len(Password) < 4 Then
    WPW = "In Valid Password : "
    CNT = 5
    End If
    If (not validate(Passwo rd)) then
    WPW = "In Valid Password : "
    CNT = 5
    end if
    RPassword = Trim (Request("RPass word"))
    If Len(RPassword) > 20 or Len(RPassword) < 4 Then
    WRPW = "In Valid Repeat Password : "
    CNT = 5
    End If
    If (not validate(RPassw ord)) then
    WRPW = "In Valid Repeat Password : "
    CNT = 5
    end if
    If Password <> RPassword Then
    WPW = "Password and Repeate Password Do Not Match : "
    WRPW = "Password and Repeate Password Do Not Match : "
    CNT = 5
    end if
    Name = Trim (Request("Name" ))
    If Len(Name) > 150 or Len(Name) < 3 Then
    WN= "In Valid Name : "
    CNT = 5
    End If
    If (not validate(Name)) then
    WN = "In Valid Name : "
    CNT = 5
    end if
    Designation = Trim (Request("Desig nation"))
    If Len(Designation ) > 50 or Len(Designation ) < 2 Then
    WDe = "In Valid Designation : "
    CNT = 5
    End If
    If (not validate(Design ation)) then
    WDe = "In Valid Designation : "
    CNT = 5
    end if
    Web = Trim (Request("Web") )
    If Len(Web) > 100 or Len(Web) < 4 Then
    WWe = "In Valid Web URL : "
    CNT = 5
    End If
    If (not validate(Web)) then
    WWe = "In Valid Web URL : "
    CNT = 5
    end if
    Company = Trim (Request("Compa ny"))
    If Len(Company) > 100 or Len(Company) < 4 Then
    WCO = "In Valid Company : "
    CNT = 5
    End If
    If (not validate(Compan y)) then
    WCO = "In Valid Company : "
    CNT = 5
    end if
    Industry = Trim (Request("Indus try"))
    If Len(Industry) > 50 or Len(Industry) < 2 Then
    WIn = "In Valid Industry : "
    CNT = 5
    End If
    If (not validate(Indust ry)) then
    WIn = "In Valid Industry : "
    CNT = 5
    End if
    CompanyType = Trim (Request("Compa nyType"))
    If Len(CompanyType ) > 100 or Len(CompanyType ) < 2 Then
    WCT = "In Valid Company Type : "
    CNT = 5
    End If
    If (not validate(Compan yType)) then
    WCT = "In Valid Company Type : "
    CNT
    End If
    Email = Trim (Request("Email "))
    If Len(Email) > 75 or Len(Email) < 4 Then
    WEID = "In Valid Email ID : "
    CNT = 5
    End If
    If (not validate(Email) ) then
    WEID = "In Valid Email ID : "
    CNT = 5
    end if
    If Len(Email) >= 4 Then
    EmailatRate = InStr(Email, "@")
    If EmailatRate < 2 Then
    WEID = "InValid Email ID"
    CNT = 5
    End If
    EmailatRate1 = InStr(Email, ".")
    If EmailatRate1 < 2 Then
    WEID = "InValid Email ID"
    CNT = 5
    End if
    End if
    Phone = Trim (Request("Phone "))
    If Len(Phone) > 15 or Len(Phone) < 5 Then
    WPh = "In Valid Phone : "
    CNT = 5
    End If
    If (not validate(Phone) ) then
    WPh = "In Valid Phone ID : "
    CNT = 5
    end if
    Mobile = Trim (Request("Mobil e"))
    If Len(Mobile) > 15 or Len(Mobile) < 10 Then
    WMO = "In Valid Mobile Number : "
    CNT = 5
    End If
    If (not validate(Mobile )) then
    WMO = "In Valid Mobile Number : "
    CNT = 5
    end if
    Add = Trim (Request("Add") )
    If Len(Add) > 200 or Len(Add) < 4 Then
    WAdd = "In Valid Address : "
    CNT = 5
    End If
    If (not validate(Add)) then
    WAdd = "In Valid Address : "
    CNT = 5
    end if
    City = Trim (Request("City" ))
    If Len(City) > 50 or Len(City) < 4 Then
    WCy = "In Valid City : "
    CNT = 5
    End If
    If (not validate(City)) then
    WCy = "In Valid City : "
    CNT = 5
    end if
    State = Trim (Request("State "))
    If Len(State) > 50 or Len(state) < 4 Then
    WSt = "In Valid State : "
    CNT = 5
    End If
    If (not validate(State) ) then
    WSt = "In Valid State : "
    CNT = 5
    end if
    Pin = Trim (Request("Pin") )
    If Len(Pin) > 15 or Len(Pin) < 4 Then
    WPN = "In Valid Pin Number : "
    CNT = 5
    End If
    If (not validate(Pin)) then
    WPN = "In Valid Pin Number : "
    CNT = 5
    end if
    Country = Trim (Request("Count ry"))
    If Len(Country) > 100 or Len(Country) < 2 Then
    WCO = "In Valid Country : "
    CNT = 5
    End If
    If (not validate(Countr y)) then
    WCO = "In Valid Country : "
    CNT = 5
    end if
    If CNT < 5 Then
    '--------------Get the IP Address of the Person Signing Up
    YourIP = Request.ServerV ariables("Remot e_Host")
    %>
    <!--#include file="datacon.a sp"-->
    <%
    '-----------Open DataBase Connections
    Set Conn = Server.CreateOb ject ("ADODB.Connect ion")
    Conn.Open xDb_Conn_Str
    '-------------Open Database to Check Email ID Exists
    Set CSql = Conn.Execute("S ELECT * FROM Employer where LoginID = '" & LoginID & "'")
    If CSql.EOF Then
    OK = "Yes"
    else
    WLID = "Login ID Already Exists"
    CNT = 5
    End If
    End If
    '----------Insret Account
    If CNT < 5 Then
    YourIP = Request.ServerV ariables("Remot e_Host")
    JoinDate = Date()
    Status = "Pending"
    Level = "Administra tor"
    sSql = "insert into [Employer] ([LoginID], [Name],[Designation], [Company], [Industry], [CompanyType], [Email], [Phone], [Mobile], [Add1], [City], [State], [Pin], [Country], [JoinDate], [IP], [Accounts], [Status], [Logins], [Web]) values ('"& LoginID & "', '"& Name &"', '"& Designation & "', '"& Company & "', '"& Industry & "', '"& CompanyType & "', '"& Email & "', '"& Phone & "', '"& Mobile & "', '"& Add & "', '"& City & "', '"& State & "', '"& Pin & "', '"& Country & "', '"& JoinDate & "', '"& YourIP & "', 1, '"& Status &"',0, '"& Web &"')"
    Conn.Execute sSql
    Set NSql = Conn.Execute("S ELECT * FROM Employer where LoginID = '" & LoginID & "'")
    ID = NSql("ID")
    sSql1 = "insert into [EmployerSub] ([ID],[LoginID], [Password], [Level], [Status]) values ('"& ID & "', '"& LoginID & "', '"& Password & "', '"& Level &"', 'InActive')"
    Conn.Execute sSql1
    End If
    '----------------End of Account Creations
    '--------------Create CDonts
    If CNT < 5 Then
    Set objCDO = Server.CreateOb ject("CDONTS.Ne wMail")
    objCDO.To = Email
    objCDO.From = "------------------------"
    objCDO.cc = "------------------------"
    txtSubject = "If you have not Submitted and the following details are not yours please send a mail to us at -------------------------- with DELETE as the subject from this Email Id -" & Email & " " & vbcrlf&_
    "______________ _______________ _______________ ______ __________"& vbcrlf&_
    " " & vbcrlf&_
    "Dear "& Name & ","& vbcrlf&_
    " "& vbcrlf&_
    "Thank You For Registering at ----------------------"& vbcrlf&_
    "Your Registered Details are as follows -"& vbcrlf&_
    " "& vbcrlf&_
    "Name - "& Name & ""& vbcrlf&_
    "Company - "& Company & ""& vbcrlf&_
    "Login ID - "& LoginID & ""& vbcrlf&_
    "Password - "& Password & ""& vbcrlf&_
    " "& vbcrlf&_
    "Your Login URL is - ----------------------------/eLogin.asp"&vbc rlf&_
    " "& vbcrlf&_
    "You can use your Login ID and Password to Access Your Employer Account. " & vbcrlf&_
    "Best Wishes"&vbcrlf& _
    ""& vbcrlf&_
    ""
    objCDO.Subject = " Employer Account Creation"
    '-----------End Of Mail Copy
    objCDO.Body = txtSubject
    objCDO.Send
    '---------------If All Validation are OK Redirect to eLogin Page
    Response.Redire ct("elogin.asp" )
    Conn.close
    set Conn = nothing
    End If
    End If
    %>
    <!--#include file="eheader.a sp"-->
    <SCRIPT TYPE="text/javascript" src=formval.js> </SCRIPT>
    <SCRIPT TYPE="text/javascript">
    // Only script specific to this form goes here.
    // General-purpose routines are in a separate file.
    function validateOnSubmi t() {
    var elem;
    var errs=0;
    // execute all element validations in reverse order, so focus gets
    // set to the first one in error.
    if (!validateEmail (document.forms .signup.Email, 'inf_Email', true)) errs += 1;
    if (!validatePrese nt(document.for ms.signup.Login ID, 'inf_LoginID')) errs += 1;
    if (!validatePrese nt(document.for ms.signup.Passw ord, 'inf_Password') ) errs += 1;
    if (!validatePrese nt(document.for ms.signup.FName , 'inf_Name')) errs += 1;
    if (!validatePrese nt(document.for ms.signup.Add, 'inf_Add')) errs += 1;
    if (!validatePrese nt(document.for ms.signup.City, 'inf_City')) errs += 1;
    if (!validatePrese nt(document.for ms.signup.Zip, 'inf_Zip')) errs += 1;
    if (!validatePrese nt(document.for ms.signup.State , 'inf_State')) errs += 1;
    if (!validatePrese nt(document.for ms.signup.Count ry, 'inf_Country')) errs += 1;
    if (!validatePrese nt(document.for ms.signup.Phone , 'inf_Phone')) errs += 1;

    if (errs>1) alert('There are fields which need correction before sending');
    if (errs==1) alert('There is a field which needs correction before sending');

    return (errs==0);
    };
    </SCRIPT>

    And also

    +============== =============== ==============+

    <%
    '--------------Get the IP Address of the Person Signing Up
    IP = Request.ServerV ariables("Remot e_Host")
    '-------------Validate the Email and Password for possible mischief
    function validate(input)
    bad_strings = array("'", "select", "union", "insert", "--")
    for each i in bad_strings
    if ( inStr(input, i) <> 0) then
    validate = false
    exit function
    end if
    next
    validate = true
    end function
    '-----------------Get the Form Details
    FName = Trim (Request("FName "))
    FName = Replace(FName, "'", "''")
    If Len(FName) > 75 Then response.redire ct("Error.asp?O K=First Name is Over 75 Char")
    If Len(FName) < 4 Then response.redire ct("Error.asp?O K=First Name Should be at Least 4 Characters Long!")
    If (not validate(FName) ) then
    response.redire ct("Error.asp?O K=Invalid First Name")
    end if
    LName = Trim (Request("LName "))
    LName = Replace(LName, "'", "''")
    If Len(LName) > 75 Then response.redire ct("Error.asp?O K=Last Name is Over 75 Char")
    If Len(LName) < 4 Then response.redire ct("Error.asp?O K=Last Name Should be at Least 4 Characters Long!")
    If (not validate(LName) ) then
    response.redire ct("Error.asp?O K=Invalid Last Name")
    end if
    Sex = Trim (Request("Sex") )
    Sex = Replace(Sex, "'", "''")
    If Sex = "Male" Or Sex = "Female" Then
    '
    Else
    Sex = "Male"
    End If
    DOBD = Request("Day")
    If Len(DOBD) < 1 Then response.redire ct("Error.asp?O K=Date Required")
    DOBM = Request("Month" )
    If Len(DOBM) < 1 Then response.redire ct("Error.asp?O K=Date Required")
    DOBY = Request("Year")
    If Len(DOBY) < 1 Then response.redire ct("Error.asp?O K=Date Required")
    If DOBD > 29 And DOBM = "February" Then response.redire ct("Error.asp?O K=Invalid Date-1")
    If DOBD > 30 And (DOBM = "February" or DOBM = "April" or DOBM = "June" or DOBM = "September" or DOBM = "November") Then response.redire ct("Error.asp?O K=Invalid Date-2")
    DOBY1 = DOBY/4
    DOBY1 = InStr(DOBY1, ".")
    If DOBD = 29 And DOBM = "February" And DOBY1 > 0 Then response.redire ct("Error.asp?O K=Invalid Date-3")
    If Len(Company) > 10 Then response.redire ct("Error.asp?O K=Invalid Date")
    If (not validate(DOBD)) then
    response.redire ct("Error.asp?O K=Invalid Day")
    end if
    If (not validate(DOBM)) then
    response.redire ct("Error.asp?O K=Invalid Month")
    end if
    If (not validate(DOBY)) then
    response.redire ct("Error.asp?O K=Invalid Year")
    end if
    Mobile = Trim (Request("Mobil e"))
    Mobile = Replace(Mobile, "'", "''")
    If Len(Mobile) > 15 Then response.redire ct("Error.asp?O K=Mobile Number is Over 15 Char")
    If Len(Mobile) < 10 Then response.redire ct("Error.asp?O K=Mobile Number Should be at Least 10 Characters Long!")
    If (not validate(Mobile )) then
    response.redire ct("Error.asp?O K=Invalid Mobile Number")
    end if
    Landline = Trim (Request("Landl ine"))
    Landline = Replace(Landlin e, "'", "''")
    If Len(Landline) > 15 Then response.redire ct("Error.asp?O K=Landline is Over 15 Char")
    If Len(Landline) < 5 Then response.redire ct("Error.asp?O K=Landline Number Should be at Least 5 Characters Long!")
    If (not validate(Landli ne)) then
    response.redire ct("Error.asp?O K=Invalid Landline Number")
    end if
    Qualification = Trim (Request("Quali fication"))
    Qualification = Replace(Qualifi cation, "'", "''")
    If Len(Qualificati on) > 25 Then response.redire ct("Error.asp?O K=Qualification is Over 25 Char")
    If Len(Qualificati on) < 2 Then response.redire ct("Error.asp?O K=Qualification Should be at Least 2 Characters Long!")
    If (not validate(Qualif ication)) then
    response.redire ct("Error.asp?O K=Invalid Qualification Entry!")
    end if
    Institute = Trim (Request("Insti tute"))
    Institute = Replace(Institu te, "'", "''")
    If Len(Institute) > 75 Then response.redire ct("Error.asp?O K=Institute is Over 75 Char")
    If Len(Institute) < 4 Then response.redire ct("Error.asp?O K=Institute Should be at Least 4 Characters Long!")
    If (not validate(Instit ute)) then
    response.redire ct("Error.asp?O K=Invalid Institute Entry!")
    end if
    CurrentLocation = Trim (Request("Curre ntLocation"))
    CurrentLocation = Replace(Current Location, "'", "''")
    If Len(CurrentLoca tion) > 50 Then response.redire ct("Error.asp?O K=CurrentLocati on is Over 50 Char")
    If Len(CurrentLoca tion) < 4 Then response.redire ct("Error.asp?O K=CurrentLocati on Should be at Least 4 Characters Long!")
    If (not validate(Curren tLocation)) then
    response.redire ct("Error.asp?O K=Invalid CurrentLocation Entry!")
    end if
    PreferredLocati on = Trim (Request("Prefe rredLocation"))
    PreferredLocati on = Replace(Preferr edLocation, "'", "''")
    If Len(PreferredLo cation) > 50 Then response.redire ct("Error.asp?O K=PreferredLoca tion is Over 50 Char")
    If Len(PreferredLo cation) < 4 Then response.redire ct("Error.asp?O K=PreferredLoca tion Should be at Least 4 Characters Long!")
    If (not validate(Prefer redLocation)) then
    response.redire ct("Error.asp?O K=Invalid PreferredLocati on Entry!")
    end if
    WorkExperiencY = Trim (Request("WorkE xperiencY"))
    If Len(WorkExperie ncY) > 10 Then response.redire ct("Error.asp?O K=WorkExperienc Y is Over 10 Char")
    If Len(WorkExperie ncY) < 1 Then response.redire ct("Error.asp?O K=WorkExperienc Y Should be at Least 1 Characters Long!")
    If (not validate(WorkEx periencY)) then
    response.redire ct("Error.asp?O K=Invalid WorkExperiencY Entry!")
    end if
    WorkExperiencM = Trim (Request("WorkE xperiencM"))
    If Len(WorkExperie ncM) > 10 Then response.redire ct("Error.asp?O K=WorkExperienc M is Over 10 Char")
    If Len(WorkExperie ncM) < 1 Then response.redire ct("Error.asp?O K=WorkExperienc M Should be at Least 1 Characters Long!")
    If (not validate(WorkEx periencM)) then
    response.redire ct("Error.asp?O K=Invalid WorkExperiencM Entry!")
    end if
    CurrentIndustry = Trim (Request("Curre ntIndustry"))
    CurrentIndustry = Replace(Current Industry, "'", "''")
    If Len(CurrentIndu stry) > 100 Then response.redire ct("Error.asp?O K=CurrentIndust ry is Over 100 Char")
    If (not validate(Curren tIndustry)) then
    response.redire ct("Error.asp?O K=Invalid CurrentIndustry Entry!")
    end if
    Relocate = Trim (Request("Reloc ate"))
    If Relocate = "Yes" Or Relocate = "No" Then
    Else
    Relocate = "Yes"
    End If
    CCTCL = Request("CCTCL" )
    CCTCT = Request("CCTCT" )
    ECTCL = Request("ECTCL" )
    ECTCT = Request("ECTCT" )
    CurrentEmployer = Trim (Request("Curre ntEmployer"))
    CurrentEmployer = Replace(Current Employer, "'", "''")
    If Len(CurrentEmpl oyer) > 75 Then response.redire ct("Error.asp?O K=CurrentEmploy er is Over 75 Char")
    If (not validate(Curren tEmployer)) then
    response.redire ct("Error.asp?O K=Invalid CurrentEmployer Entry!")
    end if
    PreviousEmploye r = Trim (Request("Previ ousEmployer"))
    PreviousEmploye r = Replace(Previou sEmployer, "'", "''")
    If Len(PreviousEmp loyer) > 75 Then response.redire ct("Error.asp?O K=PreviousEmplo yer is Over 75 Char")
    If (not validate(Previo usEmployer)) then
    response.redire ct("Error.asp?O K=Invalid PreviousEmploye r Entry!")
    end if
    Skills = Trim (Request("Skill s"))
    Skills = Replace(Skills, "'", "''")
    If Len(Skills) > 250 Then response.redire ct("Error.asp?O K=Skills is Over 250 Char")
    If Len(Skills) < 5 Then response.redire ct("Error.asp?O K=Skills Should be at Least 5 Characters Long!")
    If (not validate(Skills )) then
    response.redire ct("Error.asp?O K=Invalid Skills Entry!")
    end if
    Role = Trim (Request("Role" ))
    Role = Replace(Role, "'", "''")
    If Len(Role) > 50 Then response.redire ct("Error.asp?O K=Role is Over 50 Char")
    If Len(Role) < 5 Then response.redire ct("Error.asp?O K=Role Should be at Least 5 Characters Long!")
    If (not validate(Role)) then
    response.redire ct("Error.asp?O K=Invalid Role Entry!")
    end if
    Title = Trim (Request("Title "))
    Title = Replace(Title, "'", "''")
    If Len(Title) > 75 Then response.redire ct("Error.asp?O K=Title is Over 75 Char")
    If Len(Title) < 2 Then response.redire ct("Error.asp?O K=Title Should be at Least 2 Characters Long!")
    If (not validate(Title) ) then
    response.redire ct("Error.asp?O K=Invalid Title Entry!")
    end if
    JResume = Trim (Request("Resum e"))
    JResume = Replace(JResume , "'", "''")
    If Len(Title) > 10000 Then response.redire ct("Error.asp?O K=Resume is Over 10000 Char")
    If (not validate(JResum e)) then
    response.redire ct("Error.asp?O K=Invalid Resume Entry!")
    end if
    Email = Trim (Request("Email ID"))
    Email = Replace(Email, "'", "")
    If Len(Email) > 85 Then response.redire ct("Error.asp?O K=Email is Over 85 Char")
    If Len(Email) < 5 Then response.redire ct("Error.asp?O K=EmailID Should be at Least 5 Characters Long!")
    Password = Trim (Request("Passw ord"))
    Password = Replace(Passwor d, "'", "")
    If Len(Password) >= 20 Then response.redire ct("Error.asp?O K=Password is Over 20 Char")
    If Len(Password) < 5 Then response.redire ct("Error.asp?O K=Password Should be at Least 5 Characters Long!")
    If (not validate(Email) or not validate(Passwo rd) or not validate(LoginI D)) then
    response.redire ct("Error.asp?O K=Invalid Email ID / Password")
    end if
    EmailC = Trim (Request("Email IDC"))
    If EmailC = Email Then
    '
    Else
    response.redire ct("Error.asp?O K=EmailID and Confirm Email ID Do not Match!")
    End If
    '-------If email id is not valid Redirect to the Sign UP Page Again.
    If Len(Email) < 4 Then
    response.redire ct("Error.asp?O K=InValid Email")
    end If
    If Len (Email) > 4 Then
    Elen = Len(Email)
    St = 1
    do while Elen > 0
    var = Mid(Email, st, 1)
    If var = "@" Then
    Elen = 0
    Else
    st = st + 1
    Elen = Elen - 1
    End If
    Loop
    If var <> "@" Then
    randr = "Error.asp?OK=I nValid Email"
    Response.Redire ct(randr)
    End If
    end if
    %>
    <!--#include file="datacon.a sp"-->
    <%
    DABase = "Data"
    '-----------Open DataBase Connections
    Set Conn = Server.CreateOb ject ("ADODB.Connect ion")
    Conn.Open xDb_Conn_Str
    '-------------Open Database to Check Email ID Exists
    Set CSql = Conn.Execute("S ELECT * FROM Seeker where EmailID = '" & Email & "'")
    If CSql.EOF Then
    OK = "Yes"
    else
    OK = "Email ID Already Exists"
    End If
    '----------Insret Account
    If OK = "Yes" Then
    JDate = Date()
    DOB = Request("DOB")
    sSql = "insert into [Seeker] ([EmailID], [Password], [FName], [LName], [DOBDay], [DOBMonth], [DOBYear], [JDate], [Sex], [Mobile], [Landline], [Qualification], [Institute], [CurrentLocation], [PreferredLocati on], [TotalWorkExpY], [TotalWorkExpM], [CurrentIndustry], [Relocate], [CCTCL], [CCTCT], [ECTCL], [ECTCT], [CurrentEmployer], [PreviousEmploye r], [Skills], [Role], [Title], [Resume], [IP]) values ('"& Email & "', '"& Password & "', '"& FName & "', '"& LName & "', '"& DOBD & "', '"& DOBM & "', '"& DOBY & "', '"& JDate & "', '"& Sex & "', '"& Mobile & "', '"& Landline & "', '"& Qualification & "', '"& Institute & "', '"& CurrentLocation & "', '"& PreferredLocati on & "', '"& WorkExperiencY & "', '"& WorkExperiencM & "', '"& CurrentIndustry &"', '"& Relocate &"', '"& CCTCL &"', '"& CCTCT &"', '"& ECTCL &"', '"& ECTCT &"', '"& CurrentEmployer & "', '"& PreviousEmploye r & "', '"& Skills & "', '"& Role & "', '"& Title &"', '"& JResume & "', '"& IP &"')"
    Conn.Execute sSql
    End If
    '----------------End of Account Creations
    '--------------Create CDonts
    If OK = "Yes" Then
    Set objCDO = Server.CreateOb ject("CDONTS.Ne wMail")
    objCDO.To = Email
    objCDO.From = "-----------------------------"
    objCDO.cc = "--------------"
    txtSubject = "If you have not Submitted and the following details are not yours please send a mail to us at ---------------- with DELETE as the subject from this Email Id -" & Email & " " & vbcrlf&_
    "______________ _______________ _______________ ______ __________"& vbcrlf&_
    " " & vbcrlf&_
    "Dear "& FName & " " & LName & ","& vbcrlf&_
    " "& vbcrlf&_
    "Thank You For Registering at --------"& vbcrlf&_
    "Your Registered Details are as follows -"& vbcrlf&_
    " "& vbcrlf&_
    "Login ID - "& Email & ""& vbcrlf&_
    "Password - "& Password & ""& vbcrlf&_
    " "& vbcrlf&_
    "Your Login URL is - ----------/JLogin.asp"&vbc rlf&_
    " "& vbcrlf&_
    "You can use your Login ID and Password to Access Your Account. " & vbcrlf&_
    " "&vbcrlf&_
    "Best Of Luck"&vbcrlf&_
    ""& vbcrlf&_
    ""
    objCDO.Subject = "-------------------------------"
    '-----------End Of Mail Copy
    objCDO.Body = txtSubject
    objCDO.Send
    Dim var3
    End If
    '---------------If the Email Or ID Exists Redirect the Applicant to the Error Page
    If OK = "Yes" Then
    c3 = "JLogin.asp "
    else
    c3 = "Error.asp? OK=" & OK
    end if
    Response.Redire ct(c3)
    Conn.close
    set Conn = nothing
    %>
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    The answer to your problem can be 1 of 2 things

    Option 1) Set up the Error.asp page to always redirect back to the original page (this is not good style or efficient processing, but it might be your quickest solution)

    So in your error.asp page you would need to set up something like this :
    [code=asp]
    dim NewOK
    'this will get the parameter sent by the original registration page
    NewOK = response.querys tring("OK")
    'this will send them right back to the registration page with the error passed
    response.redire ct("registratio npage.asp?OK=" & NewOK & "")
    [/code]

    Then you would need to move all your code that handled the printing of the error message from error.asp to the registrationpag e.asp.

    Silly isn't it? This basically means error.asp becomes useless page, but like i said it would be a very quick and dirty solution. Thats why option 2 is actually better


    Option 2: Change registrationpag e.asp\login page to handle all errors

    This would mean going through the entire code you posted and replacing the

    response.redire ct("error.asp?O K=InvalidUser")

    with

    response.redire ct("registratio npage.asp?OK=In validUser")

    THEN after that you would move all the code that handles printing the error information from error.asp into registrationpag e.asp and\or your login page.

    This completely eliminates error.asp, so if it has any other functions you might need to move those too (such as log writing, etc).

    If you need more help let me know

    Comment

    • satishknight
      New Member
      • Jan 2008
      • 4

      #3
      Thanks that was a quick solution and responding so fast i never expected i would get a reply at this pace, i am really happy to be on this forum its great.

      Well first the solution was really ingenious, well i have another doubt now because it gets redirected again to the registration page as per your solution all the data typed by the registrants will be gone. Now how do i go about doing a change that will validate the data entered and then show the error in the same page so that the there is no data loss whatever was entered cos every time its wrong during registration then it will be redirected to the same page with blank information.

      Also in some fields i want the sample data to be shown when they click on the text box (i dont want the data to be present in the text box but it should pop up (Ex; The ajax feature). Can you help me. I am sorry if its annoying i am not an expert in asp.

      For Example of the text box pop please see this link if possible. Thanks for your patience.

      Register with Naukri.com & receive jobs in your inbox, apply to jobs easily. Find the right Job by top employers from India & abroad. Create your Profile Now, Free!.

      Comment

      • jeffstl
        Recognized Expert Contributor
        • Feb 2008
        • 432

        #4
        Originally posted by satishknight
        Thanks that was a quick solution and responding so fast i never expected i would get a reply at this pace, i am really happy to be on this forum its great.

        Well first the solution was really ingenious, well i have another doubt now because it gets redirected again to the registration page as per your solution all the data typed by the registrants will be gone. Now how do i go about doing a change that will validate the data entered and then show the error in the same page so that the there is no data loss whatever was entered cos every time its wrong during registration then it will be redirected to the same page with blank information.

        Also in some fields i want the sample data to be shown when they click on the text box (i dont want the data to be present in the text box but it should pop up (Ex; The ajax feature). Can you help me. I am sorry if its annoying i am not an expert in asp.

        For Example of the text box pop please see this link if possible. Thanks for your patience.

        http://my.naukri.com/manager/createa...cp=5422&wExp=N
        Oh ok.

        I understand your problem.

        What you will need to do probably is use Session variables. These are variable that are maintained throughout a user's session, no matter which page they are on.

        The way you set a session variable is simple.
        [code=asp]
        Session("NewNam e") = request.form("t xtName")
        [/code]

        OK. So now that you have it you can reprint it out when they are redirected
        [code=asp]
        <input type="text" name="txtName" value="<%Sessio n("NewName")%>" >
        [/code]

        So now that you are introducing this however, you need to make sure you check if they are being redirected. If they are not being redirected you must clear out the session variables to blanks to make sure they are not holding old data or something.

        [code=asp]
        if UserRedirected = "True" then
        Session("NewNam e") = ""
        end if
        [/code]

        As you may have noticed your issue does open up alot of problems. This is why it is much better form to use a single page to handle all errors and validations, especially in classic ASP.

        That way you dont have to worry about holding variables values between pages all the time, it does get tedious.

        Good luck, hopefully this helps you out.

        Oh and as far as printing out error examples you just need a conditional response.write to handle it everywhere on the page you want validation messages.

        [code=asp]
        if UserError1 <> "" then 'check if error is blank
        response.write MyErrorMsg
        else
        'do nothing
        end if
        [/code]

        Comment

        Working...