|
| |
|
|
MariaK
Posts: 55 Joined: 6/21/2004 Status: offline
|
Frontpage2003 and ASP database problem - 8/4/2004 15:20:24
Hi Can anyone help me regarding the following query:- I am following the steps based on an Article given in Microsoft site "How to Create a Password-Protected Web Page by Using Microsoft Office FrontPage 2003, Active Server Pages (ASP), and a Microsoft Access database" and the link is :- http://support.microsoft.com/default.aspx?scid=kb;en-us;825498 but some how the logon page and the password protected page both of them are not working. If Any of you have any idea about this problem do reply I am doing exactly what is given but still its not working
|
|
|
|
MariaK
Posts: 55 Joined: 6/21/2004 Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/4/2004 15:22:22
I just forgot to mention that instead of Access i am using Excel file as Database
|
|
|
|
BeTheBall
Posts: 6354 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/4/2004 15:33:27
When you say, "It isn't working", are you getting an error message? Why Excel? I wouldn't recommend Excel for this type of thing, unless you have absoluted no choice. Have you considered the Spooky Login? That will provide you a very secure, easy to use system for protecting any page(s) you wish. I highly recommend it for its ease of use and because at $29.95 it will save you hours of programming and debugging. In fact, if the price is too high, try the free version.
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
MariaK
Posts: 55 Joined: 6/21/2004 Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/4/2004 15:45:23
No there are no error messages just the page is not coming up in the browser, it shows the page cannot be displayed. The problem behind using Excel is that the company for whom i am designing the website want it like that as its easier for them to maintain and use the database file. i don't have any other options left except using Excel. I have not tried using Spooky Login, moreover i don't want to spend as its not for my personal use. anyway, i will try the free version, otherwise i really surprised by the fact that how the steps given in microsoft site isn't working??
|
|
|
|
MariaK
Posts: 55 Joined: 6/21/2004 Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/4/2004 17:46:27
Only one password for each user and the code for logon.asp is :-
<%
'Was this page posted to?
if UCase(Request.ServerVariables("HTTP_METHOD"))="POST"
Then
'if so, check the username/password that was entered.
if ComparedPassword(Request("UID"),Request("PWD"))
Then
'if comparision was good, store the user name...
Session("UID")=Request("UID")
'......and redirect back to the original page.
Response.Redirect Session("REFERRER")
end if
end if
%>
<html>
<head>
<title>Logon Page</title>
<style>
body { font-family: arial, helvetica }
table { background-color: #cccccc; font-size: 9pt; padding: 3px }
td { color: #000000; background-color: #cccccc; border-width: 0px }
th { color: #ffffff; background-color: #0000cc; border-width: 0px }
</style>
</head>
<body bgcolor="#000000" text="#ffffff">
<h3 align="center"> </h3>
<div align="center"><center>
<form action="<%=LOGON_PAGE%>" method="POST">
<table border="2" cellpadding="2" cellspacing="2">
<tr>
<th colspan="4" align="left">Enter User Name and Password</th>
</tr>
<tr>
<td> </td>
<td colspan="2" align="left">Please type your user name and password.</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="left">Site</td>
<td align="left"><%=Request.ServerVariables("SERVER_NAME")%> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="left">User Name</td>
<td align="left"><input name="UID" type="text" size="20"></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="left">Password</td>
<td align="left"><input name="PWD" type="password" size="20"></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2" align="center"><input type="submit" value="LOGON"></td>
<td> </td>
</tr>
</table>
</form>
</center></div>
</body>
</html>
And the code for Password-Protected Page is:-
<% @language="vbscript" %>
<!--#include virtual="/logon/_private/logon.inc"-->
<html>
<head>
<title>Password Protected Page</title>
</head>
<body>
<h3>Password Protected Page </h3>
<p> You are logged on as:
<% if len(Session("UID"))=0 Then
Response.Write "<b> You are not logged on.</b>"
else
Response.Write "<b>" & Session("UID") & "</b>"
end if
%>
</p>
<p>
<a href="default.asp">Back to default</a>
</p>
</body>
</html>
And the Code for Logon.inc is
<%
' Do not cache this page.
Response.CacheControl = "no-cache"
' Define the name of the users table.
Const USERS_TABLE = "tblUsers"
' Define the path to the logon page.
Const LOGON_PAGE = "/logon/logon.asp"
' Define the path to the logon database.
Const MDB_URL = "/logon/_private/logon.xls"
' Check to see whether you have a current user name.
If Len(Session("UID")) = 0 Then
' Are you currently on the logon page?
If LCase(LOGON_PAGE) <> LCase(Request.ServerVariables("URL")) Then
' If not, set a session variable for the page that made the request...
Session("REFERRER") = Request.ServerVariables("URL")
' ...and redirect to the logon page.
Response.Redirect LOGON_PAGE
End If
End If
' This function checks for a username/password combination.
Function ComparePassword(UID,PWD)
' Define your variables.
Dim strSQL, objCN, objRS
' Set up your SQL string.
strSQL = "SELECT * FROM " & USERS_TABLE & " WHERE (UID='" & UID & "' AND PWD='" & PWD & "');"
' Create a database connection object.
Set objCN = Server.CreateObject("ADODB.Connection")
' Open the database connection object.
objCN.Open "driver={{Microsoft Excel Driver (*.xls)};DBQ=URL=" & Server.MapPath(MDB_URL) &";"
' Run the database query.
Set objRS = objCN.Execute(strSQL)
' Set the status to true/false for the database lookup.
ComparePassword = Not(objRS.EOF)
' Close your database objects.
Set objRS = Nothing
Set objCN = Nothing
End Function
%>
|
|
|
|
MariaK
Posts: 55 Joined: 6/21/2004 Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/4/2004 17:53:36
By saying that "One password for each user" i mean to say whoever wants to download whitepapers should have login id like a registered member. everyone has to register seperately with new id
|
|
|
|
MariaK
Posts: 55 Joined: 6/21/2004 Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/4/2004 18:06:32
Sorry, i missed the two lines, while copying and pasting it the logon .asp has the following code:-
<% @language="vbscript" %>
<!--#include virtual="/logon/_private/logon.inc"-->
<%
'Was this page posted to?
if UCase(Request.ServerVariables("HTTP_METHOD"))="POST"
Then
'if so, check the username/password that was entered.
if ComparedPassword(Request("UID"),Request("PWD"))
Then
'if comparision was good, store the user name...
Session("UID")=Request("UID")
'......and redirect back to the original page.
Response.Redirect Session("REFERRER")
end if
end if
%>
<html>
<head>
<title>Logon Page</title>
<style>
body { font-family: arial, helvetica }
table { background-color: #cccccc; font-size: 9pt; padding: 3px }
td { color: #000000; background-color: #cccccc; border-width: 0px }
th { color: #ffffff; background-color: #0000cc; border-width: 0px }
</style>
</head>
<body bgcolor="#000000" text="#ffffff">
<h3 align="center"> </h3>
<div align="center"><center>
<form action="<%=LOGON_PAGE%>" method="POST">
<table border="2" cellpadding="2" cellspacing="2">
<tr>
<th colspan="4" align="left">Enter User Name and Password</th>
</tr>
<tr>
<td> </td>
<td colspan="2" align="left">Please type your user name and password.</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="left">Site</td>
<td align="left"><%=Request.ServerVariables("SERVER_NAME")%> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="left">User Name</td>
<td align="left"><input name="UID" type="text" size="20"></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="left">Password</td>
<td align="left"><input name="PWD" type="password" size="20"></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2" align="center"><input type="submit" value="LOGON"></td>
<td> </td>
</tr>
</table>
</form>
</center></div>
</body>
</html>
|
|
|
|
MariaK
Posts: 55 Joined: 6/21/2004 Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/4/2004 18:09:26
quote:
Make sure that you have your browser set up to give you errors... rather than "Friendly HTTP error messages" How can i set the browser to give proper errors??
|
|
|
|
MariaK
Posts: 55 Joined: 6/21/2004 Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/4/2004 18:13:10
I have set the browser to give proper errors now i can see lots of error on the logon page
|
|
|
|
MariaK
Posts: 55 Joined: 6/21/2004 Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/4/2004 18:16:55
now its showing the following error quote:
Microsoft VBScript runtime error '800a000d' Type mismatch: 'ComparedPassword' /logon/logon.asp, line 9 when i tried to open the password protected page logon page is now working
|
|
|
|
BeTheBall
Posts: 6354 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/4/2004 22:09:36
Here are a couple more things you may need to do. In Logon.inc, find this line: objCN.Open "driver={{Microsoft Excel Driver (*.xls)};DBQ=URL=" & Server.MapPath(MDB_URL) &"; change it to: objCN.Open "driver={Microsoft Excel Driver (*.xls)};DriverID=790;DBQ=" & Server.MapPath(MDB_URL) &";" You have an extra "{" and you need to add the DriverID=790 part. Second, you need to select the columns of your Excel sheet that contain the UID and PWD and name the range tblUsers. See if that gets the job done.
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
MariaK
Posts: 55 Joined: 6/21/2004 Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/5/2004 9:20:36
Thanks Duane, I corrected those silly mistakes and finally i got another error quote:
Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Excel Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x2d0 Thread 0x78c DBC 0x1c41edc Excel'. /logon/_private/logon.inc, line 33 i am again posting the code for logon.inc
<%
' Do not cache this page.
Response.CacheControl = "no-cache"
' Define the name of the users table.
Const USERS_TABLE = "tblUsers"
' Define the path to the logon page.
Const LOGON_PAGE = "/logon/logon.asp"
' Define the path to the logon database.
Const MDB_URL = "/logon/_private/logon.xls"
' Check to see whether you have a current user name.
If Len(Session("UID")) = 0 Then
' Are you currently on the logon page?
If LCase(LOGON_PAGE) <> LCase(Request.ServerVariables("URL")) Then
' If not, set a session variable for the page that made the request...
Session("REFERRER") = Request.ServerVariables("URL")
' ...and redirect to the logon page.
Response.Redirect LOGON_PAGE
End If
End If
' This function checks for a username/password combination.
Dim UID, PWD
Function ComparePassword(UID,PWD)
' Define your variables.
Dim strSQL, objCN, objRS
' Set up your SQL string.
strSQL = "SELECT * FROM " & USERS_TABLE & " WHERE (UID='" & UID & "' AND PWD='" & PWD & "');"
' Create a database connection object.
Set objCN = Server.CreateObject("ADODB.Connection")
' Open the database connection object.
objCN.Open "DRIVER={Microsoft Excel Driver (*.xls)};DBQ=URL=/logon/_private/logon.xls;"
' Run the database query.
Set objRS = objCN.Execute(strSQL)
' Set the status to true/false for the database lookup.
ComparePassword = Not(objRS.EOF)
' Close your database objects.
Set objRS = Nothing
Set objCN = Nothing
End Function
%>
I named the cells having the column heading UID and PWD as the table name i.e tblUsers. This kind of thing once worked when i used the inbuilt mechanism of Frontpage to connect with database file instead of writting the code myself. But now :(, i don't know where i am going wrong or what should be done. Isn't there any option for making Excel as the database file??
|
|
|
|
BeTheBall
Posts: 6354 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: Frontpage2003 and ASP database problem - 8/5/2004 9:28:37
Replace this line: objCN.Open "DRIVER={Microsoft Excel Driver (*.xls)};DBQ=URL=/logon/_private/logon.xls;" with: objCN.Open "driver={Microsoft Excel Driver (*.xls)};DriverID=790;DBQ=" & Server.MapPath(MDB_URL) &";"
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|