Access on Our Web Page

mrssevans

Registered User.
Local time
Today, 22:55
Joined
Nov 15, 2001
Messages
190
I am wanting to make our database so that customers can access it and see the current status of their home. Here is what I need help with. I want the customers to have to use something to log in so they can't see everyones records. They could log in with their last name as their username and serial number as their password, but what do I use to check that they are correct? Thanks in advance!

[This message has been edited by mrssevans (edited 12-19-2001).]
 
I put together a quick example of the code needed to do what you would like here:

A proteced Page

The URL for that page is http://www.traitnet.com/demo/protected.asp

Check the URL after you click the link it will change to reflect the password.asp page.

You can click either one and they will take you to the same place. If you have not entered a password (established session) you will be redirected to the password page. From there you can enter a name and password and now the protected.asp page will be shown.

Your session will last for 3 minutes. If you do not do anything in that three minutes you will be forced to re enter the password.

Now for my disclaimer: I put this demo together on my lunch time and was in a hurry. So it may be a little sloppy. If you have a problem with the demo please let me know so that I can fix it. Also this site is being rebuilt from a back up so most of the navigation links do not work at this moment.

Having got that out of the way, there are two more things. 1) Your server must support ASP, most Windows servers do and 2) If you are interested in this demo you can have all the source, just ask!

[This message has been edited by BukHix (edited 12-19-2001).]
 
After I logged in and showed the message: "Is this something like
what you are looking for?" that was it. There was nothing after it. If it
is not too much trouble could you resend that code to me? I would very
much appreciate it.
You mentioned something about needing ASP. Could you expand on that? I am not sure what that is and our server is just a PC acting as a server, so we may not even have it. Thanks for all your help, Sam
 
After I logged in and showed the message: "Is this something like what you are looking for?" that was it. There was nothing after it.

That is all there was to the demo but you could put anything on that page including any client information that matches the login name and password. The demo I used was just an example of what is possible.

If you bookmark the "protected page" and then come back in ten minutes you are going to get the log on page again.

You mentioned something about needing ASP. Could you expand on that? I am not sure what that is and our server is just a PC acting as a server, so we may not even have it.

ASP stands for Active Server Pages which is one way to make web pages interactive. Basicaly the server compiles the script and turns it into pure HTML which then makes it possible for any borwser to view it. What OS is working as your server? Are you using PWS or IIS? Both of them will work with ASP.

If it is not too much trouble could you resend that code to me?

No trouble, thats why I offered. I am not sure how you want the code but this is probably not the best way. I will post the code on the pages later tonight so you can see how each one is used in the HTML Page.

Code:
' This code is in the page that asks for the
' name and password

<%
	Dim objRs, bolFound, objConn, strUsername
	Set objconn = Server.CreateObject("ADODB.Connection")
    objconn.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & _
	Server.MapPath("/dbtemp/admin.mdb")
  	objconn.Open
	
	strUserName = Request.Form("uname")
	strPassWord = Request.Form("pword")
	
	If ((Request.Form("uname") = "") Or (Request.Form("pword") = ""))  Then
		objConn.Close
		Set objConn = Nothing
	Else
		Set objRs = Server.CreateObject("ADODB.Recordset")
		objRs.Open "tbladmin", objConn, , adLockOptimistic, adCmdTable
		bolFound = False
		
		Do Until objRs.EOF Or bolFound
			If (strComp(objRs("uname"), strUserName, vbTextCompare) = 0) _
				And (strComp(objRs("pword"), strPassWord, vbTextCompare) = 0) Then
				bolFound = True
			Else
				objRs.MoveNext
			End If
		Loop
		
		If Not bolFound Then
			objRs.Close
			Set objRs = Nothing
			ObjConn.Close
			Set objConn = Nothing
			Response.Write "<a href='editform'>Invalid username.<P></a>"
			Response.End
		End If
		Response.Write("You made it")	
		session("loggedin") = true
		Response.Redirect ("protected.asp")	
		objRs.Close
		Set objRs = Nothing
		objConn.Close
		Set objConn = Nothing
	End If	
%>

The next file you will need should be named pwd.inc and this is the only code you need for this page.

Code:
<%
Response.Buffer = true
Session.Timeout = 03
if session("loggedin") = false then
session("calling_page") = Request.ServerVariables ("URL")
Response.Clear
Response.Redirect ("password.asp")
end if
%>

Now on any page you want to protect you just put this at the very top of your HTML page.

<!-- #include file = "pwd.inc" -->
<html>
<head><title> etc......
 
Awesome! Thanks very much.

smile.gif
 

Users who are viewing this thread

Back
Top Bottom