470,620 Members | 1,376 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,620 developers. It's quick & easy.

ASP or ASPX

Hi, I have 2 issues with the code I am using. I am unable (at the moment) to
convert from ASP to ASPX and wondering if the following code could be easily
converted to ASP ?

<asp:Label id="lblInvalid" runat="server" />

This code is being used on the login pages as described here

http://www.asp101.com/samples/login_db_aspx.asp

However I wish to integrate this code into my present page;

The code I can see in my page is

<% @language="vbscript" %>
<%
' 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
%>

And also a link to <!--#include virtual="/logon.inc"-->

<%
' Do not cache this page.
Response.CacheControl = "no-cache"

' Define the name of the users table.
Const USERS_TABLE = "Results"
' Define the path to the logon page.
Const LOGON_PAGE = "/logon/logon.asp"
' Define the path to the logon database.
Const MDB_URL = "/fpdb/register.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='" & ParseText(UID) & _
"' AND PWD='" & ParseText(PWD) & "');"
' Create a database connection object.
Set objCN = Server.CreateObject("ADODB.Connection")
' Open the database connection object.
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

' This function restricts text to alpha-numeric data only.
Function ParseText(TXT)
Dim intPos, strText, intText
For intPos = 1 TO Len(TXT)
intText = Asc(Mid(TXT,intPos,1))
If (intText > 47 And intText < 59) Or _
(intText > 64 And intText < 91) Or _
(intText > 96 And intText < 123) Then
strText = strText & Mid(TXT,intPos,1)
End if
Next
ParseText = strText
End Function
%>

Second Issue;

<% @language="vbscript" %>
<%
' 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
%>

I have a second problem with this code; When someone enters directly into
the logon page i.e. http://mydomain/logon/logon.asp

rather than referred back to a none existing page. I get an error

Response object error 'ASP 0158 : 80004005'

Missing URL

/logon/logon.asp, line 10

A URL is required.

Line 10 of the code is

' ...and redirect back to the original page.

Response.Redirect Session("REFERRER")

Kind Regards

Malcolm
May 20 '06 #1
0 1858

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Stevie_mac | last post: by
1 post views Thread by Jerry Tovar | last post: by
3 posts views Thread by Tom | last post: by
6 posts views Thread by John Lau | last post: by
3 posts views Thread by DavidS | last post: by
2 posts views Thread by WJ | last post: by
24 posts views Thread by John Rivers | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.