User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 423,546 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,971 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 3464 | Replies: 3 | Solved
Reply
Join Date: Oct 2006
Location: South Africa
Posts: 13
Reputation: Goitse is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Goitse Goitse is offline Offline
Newbie Poster

Help Creating a Login Page

  #1  
Feb 5th, 2007
Hi Guys

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

Please Help!!


Thanks in Advance
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: india
Posts: 146
Reputation: katarey is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 15
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

Tutorial Re: Creating a Login Page

  #2  
Feb 22nd, 2007
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>
Freelance Web Designer & Developer
Http//www.Katarey.com
Reply With Quote  
Join Date: Feb 2007
Posts: 2
Reputation: Mechanix is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
Mechanix Mechanix is offline Offline
Newbie Poster

Re: Creating a Login Page

  #3  
Feb 23rd, 2007
Make sure you store your .mdb file outside your www (root) folder. As anyone can download a access.mdb file if you leaving it open to the internet.

www.domain.com/database/users.mdb is open to the internet and anyone can download it.
Reply With Quote  
Join Date: Jul 2005
Location: india
Posts: 146
Reputation: katarey is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 15
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

Re: Creating a Login Page

  #4  
Feb 23rd, 2007
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
Last edited by katarey : Feb 23rd, 2007 at 1:41 pm.
Freelance Web Designer & Developer
Http//www.Katarey.com
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP Forum

All times are GMT -4. The time now is 5:57 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC