|
Talismanic -> RE: Password Protection (12/5/2001 11:56:14)
|
Yes it works on any windows server that supports ASP (most do). You have the first part in my post above. Here is the only other thing that you would need. <html> <head> <title></title> </head> <body> <form action="NameOfThisPage.asp" method="post"> <div align="center"> <table border="0" width="350"> <tr> <td width="79"><font face="Verdana" size="2">User Name</font>: </td> <td width="257"><input type="text" name="uname" size="25" maxlength="25" /></td> </tr> <tr> <td width="79"><font size="2" face="Verdana">Password</font>: </td> <td width="257"><input type="password" name="pword" size="25" maxlength="25" /></td> </tr> <tr> <td colspan="2" width="342"><p align="center"><input type="submit" value="Submit" /></p></td> </tr> </table> </div> </form> <% Dim objRs, bolFound, objConn, strUsername Set objconn = Server.CreateObject("ADODB.Connection") objconn.ConnectionString = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & _ Server.MapPath("/fpdb/DatabaseName.mdb") ' Set name here 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.End End If session("loggedin") = true Response.Redirect ("protected page") objRs.Close Set objRs = Nothing objConn.Close Set objConn = Nothing End If %> </body> </html> You need to rename the NameOfThisPage.asp to the name of your log in page. Also rename the database and the table name to match yours. The script that I posted here has been improved upon but I dont have the updated code with me. But this should get you started and I can post the newer code later on my website if you would like to see it or view a demo of how it all works. Edited by - Talismanic on 12/05/2001 11:57:44
|
|
|
|