Creating a Login Page

Thread Solved

Join Date: Oct 2006
Posts: 13
Reputation: Goitse is an unknown quantity at this point 
Solved Threads: 0
Goitse Goitse is offline Offline
Newbie Poster

Creating a Login Page

 
0
  #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
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 154
Reputation: katarey is an unknown quantity at this point 
Solved Threads: 20
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

Re: Creating a Login Page

 
0
  #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 Quick reply to this message  
Join Date: Feb 2007
Posts: 2
Reputation: Mechanix is an unknown quantity at this point 
Solved Threads: 1
Mechanix Mechanix is offline Offline
Newbie Poster

Re: Creating a Login Page

 
0
  #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 Quick reply to this message  
Join Date: Jul 2005
Posts: 154
Reputation: katarey is an unknown quantity at this point 
Solved Threads: 20
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

Re: Creating a Login Page

 
0
  #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
  1. database = Server.MapPath("../database/users.mdb")
with
  1. 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
  1. <% 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 2:41 pm.
Freelance Web Designer & Developer
Http//www.Katarey.com
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC