Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    useing if then with true or false in database

    I am having trouble in figureing out where i can put the if then statement for a true or false field in the following code

    '******************************* REQUEST VARIABLES

    username = RequestFormat(Request.Form("username"))
    pass = RequestFormat(Request.Form("pass"))
    rememberme = Request.Form("rememberme")
    submitnumber = Request.Form("submitnumber")

    '************************************ MAIN PROGRAM

    If Request.Cookies("login") = "OK" Then Response.Redirect("members.asp")

    submitnumber = submitnumber + 1

    If username <> "" AND pass <> "" Then
    Call OpenConnection()
    Dim MemberQuery
    MemberQuery = "SELECT username, pass FROM members WHERE username = '" & SQLFormat(Left(username,255)) & "' AND pass = '" & SQLFormat(Left(pass,255)) & "'"
    Set rs = Conn.Execute(MemberQuery)
    If NOT rs.EOF Then
    Response.Cookies("login") = "OK"
    Response.Redirect("members.asp")
    Else
    Call DisplayLoginForm()
    End If
    Call CloseConnection()
    Else
    Call DisplayLoginForm()
    End If

    '******************************** END MAIN PROGRAM
    p.s. whammy will find this code to be very familiar as it is from one of his zipped files Thankyou again whammy

    but what I found missing is that when you are logging in whether you have confirmed the email or not you can log in! as there is no if then statement for the confirmed field that I have noticed! I figured I was missing something so playing with the query tool that came with it I also found out that trying to put the following into the text box Select * From members WHERE confirmed = "True" doesnt work but if I change the confirmed field in the database file to a txt file instead of a true or false file it does work?? why would that be

    Thanks in advance

    Adam

  • #2
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    What database are you using?

    You might just need to remove the quotes from about "True".

    Select * From members WHERE confirmed=true

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It figures I tried like every other combination I could think of lol

    I am useing Access Database right now! I was wondering how I would change the script above so that it would check for the combined to be either true or false

    Last edited by Crash1hd; 02-14-2003 at 01:08 AM.

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You didn't take the tutorial I recommended. Hehe.

    I have some field in there called "confirmed" I think... basically you need to check when they login to make sure that confirmed is "1" or "true".
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The reason that is weird is because that is a "Bit" field. When you are using that in a SQL statement with access, you need to say True or False (with no quotes)... in the database itself it has a value of 0 (false) or 1 (true).
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually just finished doing the tutorial and now I understand how the query tool works much better however the confirmed query actualy puts either a 0 or a -1 in the field but in the query it returns true or false now I think I clicked on something in the database that changed it from showing 0 and -1 to True and false in the database

    However I will look for the confirmed field in the database file for now I get to clean up the basement so it will have to wait lol

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As long as you get it working... lol.

    Whether it's -1 or NOT, or 0 or 1, I'm not sure I totally understand the bit field myself, but I seem to be able to query it successfully, at any rate, using a boolean value. It seems to be different depending upon which database you're using...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok so what am I doing wrong with this script! lol pulling my hear out lol

    '************************************ MAIN PROGRAM

    If Request.Cookies("login") = "OK" Then Response.Redirect("members.asp")

    submitnumber = submitnumber + 1

    If username <> "" AND pass <> "" Then
    Call OpenConnection()
    Dim Member1Query
    Dim Member2Query
    Member1Query = "SELECT username, pass FROM members WHERE username = '" & SQLFormat(Left(username,255)) & "' AND pass = '" & SQLFormat(Left(pass,255)) & "'"
    Member2Query = "SELECT confirmed FROM members"
    Set RS1 = Conn.Execute(Member1Query)
    Set RS2 = Conn.Execute(Member2Query)
    If NOT RS1.EOF AND RS2("confirmed") = True Then
    Response.Cookies("login") = "OK"
    Response.Redirect("members.asp")
    Else
    Call DisplayLoginForm()
    End If
    Call CloseConnection()
    Else
    Call DisplayLoginForm()
    End If

    '******************************** END MAIN PROGRAM
    Last edited by Crash1hd; 02-14-2003 at 07:30 AM.

  • #9
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah for me determination always pans out lol the following seems to work perfectly

    '************************************ MAIN PROGRAM

    If Request.Cookies("login") = "OK" Then Response.Redirect("members.asp")

    submitnumber = submitnumber + 1

    If username <> "" AND pass <> "" Then
    Call OpenConnection()
    Dim Member1Query
    Member1Query = "SELECT username, pass, confirmed FROM members WHERE username = '" & SQLFormat(Left(username,255)) & "' AND pass = '" & SQLFormat(Left(pass,255)) & "' AND confirmed = True"
    Set RS1 = Conn.Execute(Member1Query)
    If NOT RS1.EOF Then
    Response.Cookies("login") = "OK"
    Response.Redirect("members.asp")
    Else
    Call DisplayLoginForm()
    End If
    Call CloseConnection()
    Else
    Call DisplayLoginForm()
    End If

    '******************************** END MAIN PROGRAM

    Now I just have to figure out how to make it say something different on the screen when its an invaled login as in bad password or username or check email confirmation so that they know to check there email

  • #10
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I get an error when I try to do the following

    '************************************ MAIN PROGRAM

    If Request.Cookies("login") = "OK" Then Response.Redirect("members.asp")

    submitnumber = submitnumber + 1

    If username <> "" AND pass <> "" Then
    Call OpenConnection()
    Dim Member1Query
    Member1Query = "SELECT username, pass, confirmed FROM members WHERE username = '" & SQLFormat(Left(username,255)) & "' AND pass = '" & SQLFormat(Left(pass,255)) & "' AND confirmed = True"
    Set RS = Conn.Execute(Member1Query)
    If NOT RS.EOF Then
    Response.Cookies("login") = "OK"
    Response.Redirect("members.asp")
    Else
    Call DisplayLoginForm()
    End If
    Call CloseConnection()
    Else
    Call DisplayLoginForm()
    End If

    '******************************** END MAIN PROGRAM


    '************************************* SUBROUTINES

    Sub OpenConnection() '''''''''''''''''''''''''''''
    sConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
    Mid(Server.MapPath("\"), 1, InStrRev(Server.MapPath("\"),"\")-1) & "\database\Login website users.mdb;" & _
    "Persist Security Info=False;"
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open sConnString
    End Sub ''''''''''''''''''''''''''''''''''''''''''

    Sub CloseConnection() ''''''''''''''''''''''''''''
    Conn.Close
    Set Conn = Nothing
    End Sub ''''''''''''''''''''''''''''''''''''''''''
    %>
    <% Sub DisplayLoginForm() '''''''''''''''''''''''' %>
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
    <head>
    <title>Login</title>
    </head>
    <body>
    <div>
    <% If submitnumber > 1 AND username <> "" AND pass <> "" Then %>
    <h1>Invalid Login.</h1>
    <%End If %>
    <% If RS.fields("confirmed") = False Then %>
    <h1>Check Email</h1>
    <%End If %>
    I am trying to make it so that when the reason the login is invaled due to email not being confirmed then it will tell them to check there email but when the login is invaled due to invaled username or password it wont tell them to check there email the error I get is the following

    Invalid Login.
    error '80020009'
    Exception occurred.

    /ASP Testing/Login Stuff/Login website/default.asp, line 110


    Thanks in advance

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Instead of doing it there, I'd do something like that in the "Main Program", like:

    Dim ConfirmedError
    ConfirmedError = False

    If NOT rs.EOF [b]AND rs("confirmed") = True Then
    Response.Cookies("login") = "OK"
    Response.Redirect("members.asp")
    Else
    ConfirmedError = True
    '...

    ...

    If ConfirmedError = True Then Response.Write("Oh man! You didn't answer your email!")
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #12
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    However, I already built that functionality into the program... in order to have someone confirm their account, all they have to do is go to register.asp with this in the querystring:


    confirm=theiremailaddress@theirdomain.com

    for instance:

    http://www.solidscripts.com/register...rm=bob@bob.com

    would confirm them... I have updloaded the script to demonstrate the results. Try using the path above, but a different email address, to see what happens now.
    Last edited by whammy; 02-15-2003 at 01:10 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #13
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    P.S. I just rewrote the database path for login.asp and register.asp as they should have been pointing to /database/ instead of /wwwroot/
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #14
    Regular Coder
    Join Date
    Jul 2002
    Location
    51° 03' -78" N -114° 05' 72" W
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok but your still at the same problem you are asking the person to confirm there email address yet you are still alowing them access to the website without confirming the email address which really defietes the purpose of having a confirmation! I mean dont get me wrong the rest of the script works great minus that part lol

    try it you can log in even though you haven't confirmed your email address which would be a security hole if you ask me cause then people could put nothing@none.com or what ever they want and still login and now have completly bypassed the point of having a email confirmation Hmm makes me wonder how many other sites are out there that are like that will have to check that out sometime

    Adam

  • #15
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OMG! You're right, I left that part out. LOL.

    I rewrote the script somewhat. Check it out now.

    http://www.solidscripts.com/register/logout.asp

    That will alter your login cookie...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •