Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2003
    Posts
    3

    Exclamation Unanswered: Help with Website Password Login

    Im new to website programming, and im currently making a website where i have to make a user login screen. The usernames and passwords, are stored in a SQL Database (SQL Server 2000)..

    How do i search the database for the username the user enters and checks the password to see if its right? And what program do you recommend to set this up, the easiest? - Thnaks
    Last edited by annihillation; 01-22-03 at 01:24.

  2. #2
    Join Date
    Jan 2003
    Location
    India
    Posts
    523
    using asp u can execute the sql queries to do the check.

  3. #3
    Join Date
    Jan 2003
    Location
    London, England
    Posts
    106
    Assuming you use ASP you could do something like this:

    Code:
    Username = TRIM(Request.Form("Username"))
    Password = TRIM(Request.Form("Password"))
    
    IF Username <> "" AND Password <> "" THEN
      SQL = "SELECT Password FROM users WHERE Username = '" & Username & "'"
      Database = "myconnectionstring"
      Set MyConn = Server.CreateObject("ADODB.Connection")
      MyConn.Open Database
      
      Set RS = MyConn.Execute(SQL)
      IF RS.EOF THEN
        Response.Redirect("keep_out.asp")
      ELSE
        dbPassword = TRIM(RS("Password"))
        IF Password = dbPassword THEN
          Session("mysite_login") = True
          Response.Redirect("welcome.asp")
        ELSE
          Response.Redirect("keep_out.asp")
        END IF
      END IF
    END IF
    Frettmaestro
    "Real programmers don't document, if it was hard to write it should be hard to understand!"

  4. #4
    Join Date
    Jan 2003
    Posts
    3

    Smile

    Thanks Frettmaestro. Im using an ASP webpage made in Frontpage 2002. Ill try the code, but where do i put it? Do i put it in th cade of the Submit (Login) Button? Thanks again.

  5. #5
    Join Date
    Jan 2003
    Location
    London, England
    Posts
    106
    Yes, you probably have a loginpage vith a form. You could put the code from my previous post in the top of that file, and have the form post the data to itself. Then in every page that is supposed to be protected you need to include a file that checks if the login-session has been set or not:

    check_user.asp (this is the file you include in all protected files):
    <%
    IF Session("mysite_login") <> True THEN Response.Redirect("keep_out.asp")
    %>

    And that's it! You have yourself a "secure" page...
    Frettmaestro
    "Real programmers don't document, if it was hard to write it should be hard to understand!"

  6. #6
    Join Date
    Jan 2003
    Posts
    3
    Im sorry, its not working for me. Do you hava a page you made, that uses that same code? If so, could i have the link, so i can see what your doing that im not? thanks

Posting Permissions

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