The next step is to create a table in your database called tblUsers with the following fields:
strUserName
strPassWord
Fritz the Blank
Main Topics
Browse All TopicsI wish to create a login page which will take in the user/pass combo, check them against a database and then redirect them to a start page that is stored in the database. I want all the pages that each loged in user sees to be protected and to only be accessible with the correct user/pass. I also need to create a form that will sign up new users and enter their data into a database. I am a newbie to ASP so as much step through on step as could be provided would be appreciated. I'm also in a time crunch on this. I've tried to use some of the previous answers to a similar question, but I haven't quite gotten what I'm looking for. Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Now you are ready to query the database:
<%@ Language = VBScript %>
<%Option Explicit%>
<%Response.Buffer = True%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<body bgcolor="#FFFFFF">
<%
dim strDataPath, objConnection
strDataPath = SErver.MapPath("family.mdb
set objConnection=Server.Creat
strConnectString = "Provider=Microsoft.Jet.OL
+ " Data Source= " & strDataPath & ";"_
+ " Mode=Share Deny None;User Id=admin;PASSWORD=;"
objConnection.ConnectionTi
objConnection.CommandTimeo
objConnection.Mode = 3 'adModeReadWrite
if objConnection.state = 0 then
objConnection.Open strConnectString
end if
dim strUserName, strPassWord, strSQL, bolAuthenticated
strUserName = Request.Form("cUserName")
strPassWord = Request.Form("cPassWord")
strSQL = "SELECT * FROM tblUsers Where Trim(UCase(cUserName)) = '" & Trim(UCase(strUserName)) & "'"
set objRS=Server.CreateObject(
objRS.Open strSQL,objConnection,3,3
if objRS.RecordCount > 1 then
Response.Write("There is a problem with your user name; if this problem persists, please call (###) ###-####")
Response.Write("Please try to <a href='logon.htm'> logon</a> again.<p>")
objRS.close
set objRS=Nothing
objConnection.close
set objConnection = Nothing
Response.End
end if
if objRS.RecordCount < 1 then
Response.Write("You have entered an incorrect user name; please try to <a href='logon.htm'> logon</a> again.<p>")
objRS.close
set objRS=Nothing
objConnection.close
set objConnection = Nothing
Response.End
end if
if StrComp(strPassWord, objRS("cPassWord"),1) <> 0 then
Response.Write("You have entered an incorrect pass word; please try to <a href='logon.htm'> logon</a> again.<p>")
objRS.close
set objRS=Nothing
objConnection.close
set objConnection = Nothing
Response.End
end if
Session("bolAuthenticated"
Session("iID") = objRS("nID")
call ListErrors()
call ClearRecordSet()
call ClearConnection()
Response.Redirect "main.asp"
%>
</BODY>
</HTML>
Oops, a change or two:
<%@ Language = VBScript %>
<%Option Explicit%>
<%Response.Buffer = True%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<body bgcolor="#FFFFFF">
<%
dim strDataPath, objConnection
strDataPath = SErver.MapPath("family.mdb
set objConnection=Server.Creat
strConnectString = "Provider=Microsoft.Jet.OL
+ " Data Source= " & strDataPath & ";"_
+ " Mode=Share Deny None;User Id=admin;PASSWORD=;"
objConnection.ConnectionTi
objConnection.CommandTimeo
objConnection.Mode = 3 'adModeReadWrite
if objConnection.state = 0 then
objConnection.Open strConnectString
end if
dim strUserName, strPassWord, strSQL, bolAuthenticated
strUserName = Request.Form("cUserName")
strPassWord = Request.Form("cPassWord")
strSQL = "SELECT * FROM tblUsers Where Trim(UCase(cUserName)) = '" & Trim(UCase(strUserName)) & "'"
set objRS=Server.CreateObject(
objRS.Open strSQL,objConnection,3,3
if objRS.RecordCount > 1 then
Response.Write("There is a problem with your user name; if this problem persists, please call (###) ###-####")
Response.Write("Please try to <a href='logon.htm'> logon</a> again.<p>")
objRS.close
set objRS=Nothing
objConnection.close
set objConnection = Nothing
Response.End
end if
if objRS.RecordCount < 1 then
Response.Write("You have entered an incorrect user name; please try to <a href='logon.htm'> logon</a> again.<p>")
objRS.close
set objRS=Nothing
objConnection.close
set objConnection = Nothing
Response.End
end if
if StrComp(strPassWord, objRS("cPassWord"),1) <> 0 then
Response.Write("You have entered an incorrect pass word; please try to <a href='logon.htm'> logon</a> again.<p>")
objRS.close
set objRS=Nothing
objConnection.close
set objConnection = Nothing
Response.End
end if
Session("bolAuthenticated"
Session("iID") = objRS("nID")
objRS.close
set objRS=Nothing
objConnection.close
set objConnection = Nothing
Response.Redirect "main.asp"
%>
</BODY>
</HTML>
The code above assumes that your login page is 'logon.htm' and that upon successful validation, you want your user to go to main.asp.
Also, you will need to update this line to match your environment:
strDataPath = Server.MapPath("family.mdb
Finally, you will need to put this at the top of each page that you want protected (or better yet, put it in an include file):
if (not Session("bolAuthenticated"
response.redirect("logout.
end if
if Session("iID") < 1 then
response.redirect("logout.
end if
Sorry, a few more changes (i am trying to do this quickly as you said that it is urgent).
Add one more field to your tblUsers: intID which should be an autocounter field.
The updated code is now:
<%@ Language = VBScript %>
<%Option Explicit%>
<%Response.Buffer = True%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<body bgcolor="#FFFFFF">
<%
dim strDataPath, objConnection
strDataPath = SErver.MapPath("family.mdb
set objConnection=Server.Creat
strConnectString = "Provider=Microsoft.Jet.OL
+ " Data Source= " & strDataPath & ";"_
+ " Mode=Share Deny None;User Id=admin;PASSWORD=;"
objConnection.ConnectionTi
objConnection.CommandTimeo
objConnection.Mode = 3 'adModeReadWrite
if objConnection.state = 0 then
objConnection.Open strConnectString
end if
dim strUserName, strPassWord, strSQL, bolAuthenticated
strUserName = Request.Form("strUserName"
strPassWord = Request.Form("strPassWord"
strSQL = "SELECT * FROM tblUsers Where Trim(UCase(strUserName)) = '" & Trim(UCase(strUserName)) & "'"
set objRS=Server.CreateObject(
objRS.Open strSQL,objConnection,3,3
if objRS.RecordCount > 1 then
Response.Write("There is a problem with your user name; if this problem persists, please call (###) ###-####")
Response.Write("Please try to <a href='logon.htm'> logon</a> again.<p>")
objRS.close
set objRS=Nothing
objConnection.close
set objConnection = Nothing
Response.End
end if
if objRS.RecordCount < 1 then
Response.Write("You have entered an incorrect user name; please try to <a href='logon.htm'> logon</a> again.<p>")
objRS.close
set objRS=Nothing
objConnection.close
set objConnection = Nothing
Response.End
end if
if StrComp(strPassWord, objRS("strPassWord"),1) <> 0 then
Response.Write("You have entered an incorrect pass word; please try to <a href='logon.htm'> logon</a> again.<p>")
objRS.close
set objRS=Nothing
objConnection.close
set objConnection = Nothing
Response.End
end if
Session("bolAuthenticated"
Session("intID") = objRS("intID")
objRS.close
set objRS=Nothing
objConnection.close
set objConnection = Nothing
Response.Redirect "main.asp"
%>
</BODY>
</HTML>
Fritz the Blank
I'm still not getting this to work. I just want to get a logon process that takes the password and user and comparies them to the database, and then redirects the user to a start page that is stored in the database. Again making sure that all these pages are protected is key. Any help would be appreciated I've been extended a little more time.
Okay, but do we know for sure that you have a table called tblUsers? Also, you will have to change the connection string from:
strDataPath = SErver.MapPath("family.mdb
to:
strDataPath = SErver.MapPath("homebuilde
This assumes that the database is in the same directory that your page is (something that we can change later).
FtB
Business Accounts
Answer for Membership
by: fritz_the_blankPosted on 2004-04-25 at 09:29:51ID: 10912526
Step 1) Create a form with two fields: strUserName, strPassword
Once this is done, let me know.
FtB