Results 1 to 6 of 6

Thread: Login Script

  1. #1
    Join Date
    Oct 2003
    Posts
    22

    Unanswered: Login Script

    Hi guys

    I have this login code, and i am new to ASP, i am wondering why it is not working:

    Any help would be great

    Thanks Si.

    <%
    Option Explicit

    Dim ConnStr
    Dim Conn
    Dim rst

    Sub DBConnect
    ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\wwwroot\clogin\data\webjobs.mdb"
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open ConnStr
    End Sub

    Sub DBDisconnect
    Set rst = Nothing
    Conn.Close
    Set Conn = Nothing
    End Sub

    Dim strLoginName
    Dim strLoginPassword

    strLoginName = Request.Form("txtLoginName")
    strLoginPassword = Request.Form("txtLoginPassword")

    If Len(strLoginName) > 0 Then
    Call DBConnect
    Set rst = Conn.Execute("SELECT Password FROM Candidate WHERE Email = '" & strLoginName & "'")
    If rst.EOF <> True And rst.BOF <> True Then
    If strLoginPassword = rst("Password") Then
    Session("LoggedIn") = True
    Response.Write("Username and password valid - redirecting......")
    Response.Redirect("http://www.microsoft.com")
    Else
    Session("LoggedIn") = False
    Response.Write("Email address or password not recognised!")
    End If
    Else
    Response.Write("Email address or password not recognised!")
    End If
    Call DBDisconnect
    Else
    Response.Write("Email address or password not recognised!")
    End If
    %>
    <html>

    <head>
    <title></title>
    </head>

    <body>
    </body>
    </html>

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721

    Re: Login Script

    What isn't working about it...

    the only thing I noticed at a cursory glance was this:
    Originally posted by simonfinn
    Response.Write("Username and password valid - redirecting......")
    Response.Redirect("http://www.microsoft.com")
    You cannot do a Response.Redirect once you've written to the browser. Changes to the document header (which a redirect is) can only be done before you start writing content to browser.
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    Oct 2003
    Posts
    22
    I think it is working now, but when i run the code outside visual interdev the browser opens up a download window to download the asp file.

    Any ideas why?

    Thanks Si.

  4. #4
    Join Date
    Feb 2003
    Location
    @ home
    Posts
    163
    You can leave it like you have just place this line in the middle:

    Response.Write("Username and password valid - redirecting......")

    Response.Flush

    Response.Redirect("http://www.microsoft.com")


    It will flush the line you whant and then redirect.

    Paulo

  5. #5
    Join Date
    Oct 2003
    Posts
    22
    Sorry, i forgot to say i removed that line of code.

    But i am unsure of why the browser is attempting to download the ASP page to disk instead of running the code. I thought it was that the ASP engine is not running, but it is.

    What else could cause this?

    Thanks for the help

    Si

  6. #6
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Originally posted by simonfinn
    Sorry, i forgot to say i removed that line of code.

    But i am unsure of why the browser is attempting to download the ASP page to disk instead of running the code. I thought it was that the ASP engine is not running, but it is.

    What else could cause this?

    Thanks for the help

    Si
    Make sure the website has "Execute" enabled.
    That which does not kill me postpones the inevitable.

Posting Permissions

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