Previous Next

Thread: Trouble with login script

Last post 04-30-2008 11:18 AM by tomkmvp. 8 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (9 items)

Sort Posts:

  • 04-23-2008, 1:15 PM

    • JasonCoron
    • Not Ranked
    • Joined on 01-29-2008, 6:04 PM
    • Posts 8
    • jasoncoron

    Trouble with login script

     

    I recently created an asp application (my first) in which users login to a secure section of a website to edit their personal information. It works well for 95% of the users, but a small percentage cannot login successfully. I have tried changing their user names/passwords to something very simple (to eliminate user error), but they still cannot login.

    I have tried their user names/passwords and can login, so I’m assuming it is a compatibility issue of some sort. The code from my login page is below. The user names/pws are stored in the database in the table ‘logins’.

    Any help would be greatly appreciated.

     

    Thanks,

    Jason

     ____________________

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <%
    Option Explicit
        If Session("isAdmin") = "T" Then
            If Request.QueryString("logout") <> "" then
                Session("login") = ""
                Session("targetClub") = ""
            Else
                Response.redirect "http://www.rdga.org/directory/admin/00_code/admin_page.asp"
            End If
        End If


    Function SqlEscape(s)
        SqlEscape = Replace(s,"'","''")
    End Function

    Dim targetClub       'Target Club
    Dim allaccount

    allaccount = "52-000"

    dim conn,rs,msg,rs2,rs3,getTarget,m
    If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
        Set Conn = Server.CreateObject("ADODB.Connection")
        Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/") & "\..\datafiles\directory\club_data.mdb"
       
        Set getTarget = Conn.Execute("select * from logins where login='" + SqlEscape(Request.Form("login")) + "'")
       
        If getTarget.EOF then
            msg = "Error: Invalid User Name. Be sure you are using LOWER CASE letters and NO SPACES for both the user name and password."
            m = "T"
        else
            targetClub = getTarget("club")

            Set rs3 = Conn.Execute("select * from Directory_Data where Club_Number='" & targetClub & "'")
            Session("Club_Name") = rs3("Club_Name")
           
            Set rs = Conn.Execute("select * from logins where club='" & targetClub & "' and login='" + SqlEscape(Request.Form("login")) + "'")
            Set rs2 = Conn.Execute("select * from logins where club='" & allaccount & "' and login='" + SqlEscape(Request.Form("login")) + "'")
       
       
           
            If rs("club") = allaccount then
                If rs2.EOF then
                    msg = "No such user"
                    m = "T"
                ElseIf rs2("pw") <> Request.Form("password") then
                    msg = "Invalid Passowrd"
                    m = "T"
                Else
                    Session("login") = rs2("login")
                    Session("targetClub") = "52-000"
                    Session("isAdmin") = "T"
                    Response.Redirect "http://www.rdga.org/directory/admin/00_code/admin_page.asp"
                End If
            Else
                If rs.EOF then
                    msg = "No such user"
                    m = "T"
                ElseIf rs("pw") <> Request.Form("password") then
                    msg = "Invalid Passowrd"
                    m = "T"
                Else
                    Session("login") = rs("login")
                    Session("targetClub") = targetClub
                    Session("isAdmin") = ""
                End If
            End If
        End If

           
    ElseIf Request.QueryString("logout") <> "" then
        Session("login") = ""
        Session("targetClub") = ""
        targetClub = ""

    End If

    %>

    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>RDGA Online Course Directory</title>
    <link rel="stylesheet" type="text/css" href="http://www.rdga.org/def2.css">
    </head>

    <body>

      

    <% If m = "T" Then
        Response.write(msg)
        m = ""
        End If
     %>
    <% If Session("login") = "" Then %>
    <form method="POST" action="">
    <table border="0" width="300" id="table14">
        <tr>
        <td>
            <p>Login Name</td>
            <td><input type="text" name="login" size="20"></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input type="password" name="password" size="20"></td>
        </tr>
    </table>
    <input type="submit" value="Login" name="B1"><input type="reset" value="Clear" name="B2"></form>
    <% else %>


    <b><font size="4"><% Response.Write(Session("Club_Name")) %></font></b><p align="left">
    <b><a href="http://www.rdga.org/directory/admin/00_code/edit_form.asp">
    <font color="#0000FF" size="3">Edit Club Information</font></a></b>
    <br>
    <b><a href="http://www.rdga.org/directory/admin/00_code/ghin_form.asp"><font color="#0000FF" size="3">
    GHIN/Handicap Contact Information Update</font></a></b><br>
    <b><a href="http://www.rdga.org/directory/admin/00_code/change_pw.asp"><font color="#0000FF" size="3">Change Password</font></a></b><br>
    <b><a href="http://www.rdga.org/directory/admin/00_code/login.asp?logout=1"><font color="#0000FF" size="3">Log Out</font></a></b></p>
    <p align="center">
    <% end if %>
    <% If Session("updated") = "T" Then %><b><font size="4">Update Complete!</font></b></p>
    <p>
    <% Session("updated")="" %><% End If %>

    </b>

    </body>
    </html>

     

     

  • 04-24-2008, 8:08 AM In reply to

    Re: Trouble with login script

    Explain "cannot login successfully."

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 04-24-2008, 12:44 PM In reply to

    • JasonCoron
    • Not Ranked
    • Joined on 01-29-2008, 6:04 PM
    • Posts 8
    • jasoncoron

    Re: Trouble with login script

    The user name/password combination is not accepted.
  • 04-24-2008, 2:10 PM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 3,484
    • IIS MVPs
    • tomkmvp

    Re: Trouble with login script

    It doesn't make sense that when you enter the usernames and passwords it works but does not work when they do it.  Perhaps you can add some debug "response.write" code to try and see exactly what's happening to the data ...

  • 04-24-2008, 3:47 PM In reply to

    • JasonCoron
    • Not Ranked
    • Joined on 01-29-2008, 6:04 PM
    • Posts 8
    • jasoncoron

    Re: Trouble with login script

    The mesage that they get is:

    "Error: Invalid User Name. Be sure you are using LOWER CASE letters and NO SPACES for both the user name and password."

     This is an error that users are supposed to get when the user name is not found in the table containing the user names/pws.

    I have changed these a 1 character login names for the users having trouble, and they still get the same message.

    I can login using the 1 char user name/pws from any computer I have used. Could this be some type of compatibilty issue, and if so is there an "easy" test/fix for it?

     

    Thanks for all your help. 

  • 04-30-2008, 2:23 AM In reply to

    Re: Trouble with login script

    JasonCoron:
    If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
        Set Conn = Server.CreateObject("ADODB.Connection")
        Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/") & "\..\datafiles\directory\club_data.mdb"
       
        Set getTarget = Conn.Execute("select * from logins where login='" + SqlEscape(Request.Form("login")) + "'")
       
        If getTarget.EOF then
            msg = "Error: Invalid User Name. Be sure you are using LOWER CASE letters and NO SPACES for both the user name and password."
            m = "T"
        else

     

    Hi,

    The error message occurs when getTarget.EOF is true in your code. This property indicates the current record position, when it is true the position is after the last record.

    Zhao Ji Ma
    Sincerely,
    Microsoft Online Community Support

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
  • 04-30-2008, 8:34 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 3,484
    • IIS MVPs
    • tomkmvp

    Re: Trouble with login script

    Right - which means text entered by the user did not match what is in the database.  The question is why does this work for the OP and not his users ...

  • 04-30-2008, 11:03 AM In reply to

    • JasonCoron
    • Not Ranked
    • Joined on 01-29-2008, 6:04 PM
    • Posts 8
    • jasoncoron

    Re: Trouble with login script

     So this means that the record is not being found...correct?

    I am curious as to how the same record can be found by some users and not by others (a very small percent)

     Thanks for your help.
     

  • 04-30-2008, 11:18 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 6:27 AM
    • Lawrenceville, NJ
    • Posts 3,484
    • IIS MVPs
    • tomkmvp

    Re: Trouble with login script

Page 1 of 1 (9 items)
Page view counter