Security

B

Bill

This might be too general of a question, and perhaps the
wrong group, but I will give it a try....

I have an Access database that contains 3 tables. The
database is using user level security. I would like to
write a webpage that requests userid and password, then
logs the user onto the website allowing access to the
information contained in the database for display
purposes on subsequent webpages.

Is this possible, and if so, what is the best way to go
about this?

Thanks
Bill
 
T

Trym Bagger

Your security should be based on a combination of checking against a
list of
users in a table, and then a Session variable, which is checked on all
the
pages you want to protect. You could do something along the lines of
this:


Login.asp:


<%
Dim UserName
Dim Password
UserName = Request.Form("Username")
Password = Request.Form("Password")
If Len(UserName) > 0 Then
msql = ("SELECT Username, Pw FROM users WHERE Usuario='" & UserName
& "'
AND Pw='" & Password & "'")
Set RS = Conn.Execute(msql)
If RS.EOF Then
ErrorMessage = "<P><font color=""red"">Usuario o contraseña
incorrecto</font></P>"
RS.Close
Conn.Close
Set RS = Nothing
Set Conn = Nothing
Else
RS.Close
Conn.Close
Set RS = Nothing
Set Conn = Nothing
Session("SecurityID") = "askljhsdfvljhdsfgkjlh3tkljasdlkskuh"
Response.redirect "yourpage.asp"
End If
End If
%>
<Form Method="Post" Action="login.asp">
User name: <Input Name="Username" size="15"><br>
Password: <Input Type="Password" Name="Password" size="15"><br>
<Input Type="submit" Value="Enter" Name="Login">
</Form>


(If you wan't more security, you should another function which
generates
random Session variables for each user.)


On yourpage.asp (and any other page you want to protect, you should add
the
following code at the top:


<%
If Session("SecurityID") <> "askljhsdfvljhdsfgkjlh3tkljasdlkskuh" Then
Response.Redirect "editweb.asp"
End If
%>


If you want any further assistance do not hestitate to contact me.

Cheers,

Trym Bagger
www.lacanela.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top