If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Login page returning "Page Cannot Display" error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-11-07, 01:33
sammiesue sammiesue is offline
Registered User
 
Join Date: Sep 2007
Posts: 3
Login page returning "Page Cannot Display" error

I'm trying to write login functionality using FrontPage 2003, and I keep getting the HTTP 500 - Page Cannot Be Displayed error when I launch the "logon" and the "grandrounds" page, which is where the protected content should be. It worked earlier today, I moved a few files around, and I haven't gotten it to work again. Any help is appreciated. Thanks.

Here's the code and locations in the site for the 3 pages and 1 database that are involved:

DATABASE: Root/fpdb/grandrounds.mdb

LOGIN PAGE: Root/grandrounds/login.asp
Code:
<% @language="vbscript" %>
<!--#include virtual="../_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 ComparePassword(Request("UID"),Request("PWD")) Then
      ' If comparison 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 text="#ffffff">
<h3 align="center">&#xa0;</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>&#xa0;</td>
    <td colspan="2" align="left">
     Please type your user name and password.</td>
    <td>&#xa0;</td>
  </tr>
  <tr>
    <td>&#xa0;</td>
    <td align="left">Site</td>
    <td align="left">
    <%=Request.ServerVariables("SERVER_NAME")%> &#xa0;</td>
    <td>&#xa0;</td>
  </tr>
  <tr>
    <td>&#xa0;</td>
    <td align="left">User Name</td>
    <td align="left"><input name="UID" type="text" size="20"></td>
    <td>&#xa0;</td>
  </tr>
  <tr>
    <td>&#xa0;</td>
    <td align="left">Password</td>
    <td align="left">
    <input name="PWD" type="password" size="20"></td>
    <td>&#xa0;</td>
  </tr>
  <tr>
    <td>&#xa0;</td>
    <td colspan="2" align="center">
    <input type="submit" value="Logon"></td>
    <td>&#xa0;</td>
  </tr>
</table>
</form>
</center></div>
</body>
</html>
INCLUDE FILE: Root/_private/logon.inc
Code:
<%
  ' 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   = "/grandrounds/logon.asp"
  ' Define the path to the logon database.
  Const MDB_URL      = "/fpdb/grandrounds.mdb"

  ' 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.
    ' The & _ is to continue the connection object onto 
    ' another line instead of it being on one long line
    ' You must also precede it by a quote " mark
    ' and begin the next line of the connection object
    ' with a quote " mark as normally these quote marks
    ' are not needed if it were all on one line
     objCN.Open "driver={Microsoft Access Driver (*.mdb)};" & _
    "dbq=" & Server.MapPath(MDB_URL) & "; uid=admin; pwd="
    ' 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
%>
THE DESIRED PASSWORD PAGE: Root/grandrounds/grandrounds.asp
Code:
<% @language="vbscript" %>
<!--#include virtual="_private/logon.inc"-->
<html>
<head><title>Actual Grand Rounds Page</title></head>
<body>
<h3>Actual Grand Rounds 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="../index.asp">Back to index</a>
</body>
</html>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On