Hi Guys

I'm new in ASP and Access and I 'm trying to create a login page.

Please Help!!
:confused:

Thanks in Advance

Hi there,

this will help you understand how to create login page using ASP & ACCESS,

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'This is first condition which will check user clicked on submit or not 
If Request("Submit") = "Submit" Then 

'Creating variables
dim fuser, fpass, duser, dpass

'Assigning Value to the variables which is entered by user
	fuser = Trim(Request.Form("userID"))
	fpass =  Trim(Request.Form("userPassword"))
	
'Assigning the database location into a variable, 
'Using ASP MapPath Method, The MapPath method maps a specified path to a physical path.
	database = Server.MapPath("/database/users.mdb") 

'ADO Connection Object
'The ADO Connection Object is used to create an open connection to a data source.
	set conn=Server.CreateObject("ADODB.Connection")
	conn.Provider="Microsoft.Jet.OLEDB.4.0"
	conn.Open database

'ADO Recordset Object
'The ADO Recordset object is used to hold a set of records from a database table.
'A Recordset object consist of records and columns (fields).
	set rs=Server.CreateObject("ADODB.recordset")
	rs.Open "Select * from loginInfo", conn 'Here ioginInfo is Table Name


'Assigning Value to the variables which already stored in database
		duser = Rs.Fields.Item("userName").Value
		dpass = Rs.Fields.Item("password").Value

'Now comparing both information (entered by user) with database information 
if fuser = duser And fpass = dpass Then

'If info Matched so user will redirect to the login Success page 
	Response.Redirect("Success.asp")
	
else

'else user will redirect to the same page with Message "Invalid username or password"
Response.Redirect "login.asp?msg=" & Server.URLENcode("Invalid username or password")

end if

end if 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login Page</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="login.asp">
  <table width="34%" border="0" align="center" cellpadding="3" cellspacing="03" bordercolor="#FFE5CA" bgcolor="#FFEFDF" style="border:#cccccc solid 1px;">
    <tr>
      <td colspan="2">
	  		<%
				if len(trim(request("msg"))) <> 0 then
				Response.write "<center><div><strong>"
				Response.write Request("msg")
				Response.write "</strong></div></center>"
				end if 
			%>
      </td>
    </tr>
    <tr>
      <td width="31%"><strong>User Name</strong> </td>
      <td width="69%"><input name="userID" type="text" id="userID" /></td>
    </tr>
    <tr>
      <td width="31%"><strong>Password</strong></td>
      <td width="69%"><input name="userPassword" type="password" id="userPassword" /></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">
          <input type="submit" name="Submit" value="Submit" style="text-align:center;" />
          <input type="reset" name="reset" value="Reset" style="text-align:center;" />
        </div></td>
    </tr>
  </table>
</form>
</body>
</html>

Yes! agree with Mechanix,
but for download .mdb file the name and location should know, and you can use password protection as well,

but the core thing is that you should store the mdb (database) out side of wwwroot folder :)

and if you store the (database) out side of wwwroot folder so you have to use the physical path. "C:\web_projects\My project\database\users.mdb"

just replace this line

database = Server.MapPath("../database/users.mdb")

with

database = "C:\web_projects\My project\database\users.mdb"

Note this path for example only

if you are working on web server (hosting company) not the local system so you can fine the physical path. using Server.MapPath() function

<% response.Write Server.MapPath("/") %>

create a asp file with this code, which will write the physical path of your root folder


hope this will useful for you
regards,
Rahul

This question has already been answered. Start a new discussion instead.