Hello,
I am in the way to make a login page for my new website. It must be a database driven login page.

details:
fields: username, password
database: MS Access

the guest who registering with these field; result must gone to database. so login is in compare with the above said database..

I hope somebody can help me.....

Recommended Answers

All 3 Replies

Create the database that should contains following fields
UserId,Username, password and some othere details of the user. Make UserId as Primarykey in the database.

Design Login page. mach the login user with the username and password using simple coditions if valid allow him inside other wise give message to him.
if the login user is new user provide the interface such that he can provide his infomation. and store the information in the same table.

If it is new user he must go to registeration page as well to store his or her information

thanks
www.globalsoftsols.com

Create the database that should contains following fields
UserId,Username, password and some othere details of the user. Make UserId as Primarykey in the database.

Design Login page. mach the login user with the username and password using simple coditions if valid allow him inside other wise give message to him.
if the login user is new user provide the interface such that he can provide his infomation. and store the information in the same table.

Your best bet is to pull some information out of the database to see if a user exists with your currently supplied information from the user. Use an sql query like the one below, with the code below:

<%
  Response.Buffer = true
  Session("DatabasePath") = "Path to your database, put it here. rest will fill in for you"
  If Request.Form("btnLogin") = "Login" AND Request.Form("txtUserName") <> "" AND Request.Form("txtPassword") <> "" Then

    Dim conn, strSQL, rs

    strUserName = MakeSQLSafe(Trim(Request.Form("txtName")))
    strPassword = MakeSQLSafe(Trim(Request.Form("txtPassword")))

    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Session("DatabasePath") & ";"

    strSQL = "SELECT UserName, UserID FROM Users WHERE UserName='" & strUserName & "' AND UserPassword='" & strPassword & "'"

    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open strSQL, , 0, 2

    If Not rs.EOF Then
      Session("logged") = 1
      Session("UserName") = rs("UserName")
      Session("UserID") = rs("UserID")
    Else
      Response.Redirect ("register.asp?login=failed")
    End If
    rs.Close()
    conn.Close()
    set rs = nothing
    set conn = nothing
  Else
    response.redirect ("login.asp?fields=null")
  End If
  
  Function MakeSQLSafe(sender)
    sender = Replace(sender, ";", "")
    sender = Replace(sender, """", "")
    sender = Replace(sender, "'", "")
    sender = Replace(sender, "''", "")
    Return(sender)
  End Function
%>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.