Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with User Authentication in Ultra dev

Status
Not open for further replies.

FireDesigner

Technical User
May 5, 2002
11
US
I am trying to make a portion of my site password protected. I went through the steps in Ultra Dev and created a database with a table of users in Access. I setup my conection without a DSN and used the connection string Driver={Microsoft Access Driver (*.mdb)};
DBQ=C:\decuments and settings\matt jl\desktop\framesite\newframes\users.mdb I then created an html document with a form with two text fields and a submit button. I then added the server behavior &quot;log in user&quot;, which linked my two text fields to the table of users. I created a page that would open if a correct user and password were entered and a page for an error in the user and password. I saved my files and then tried to preview the document. When I entered the user and password values in the form and hit submit it gives me a page cannot be displayed error and up in the browser adress it diplays <%=MM_LoginAction%>. I searched through my documents in ultra dev and found that the <%=MM_LoginAction%> is the action given to the form. I tried all the previous steps multiple times but always the same problem.
Here is the code:
<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;Connections/Certtest.asp&quot; -->
<%
set Recordset2 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Recordset2.ActiveConnection = MM_Certtest_STRING
Recordset2.Source = &quot;SELECT username, password FROM Table1&quot;
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 3
Recordset2.Open()
Recordset2_numRows = 0
%>
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables(&quot;URL&quot;)
If Request.QueryString<>&quot;&quot; Then MM_LoginAction = MM_LoginAction + &quot;?&quot; + Request.QueryString
MM_valUsername=CStr(Request.Form(&quot;textfield&quot;))
If MM_valUsername <> &quot;&quot; Then
MM_fldUserAuthorization=&quot;&quot;
MM_redirectLoginSuccess=&quot;history.html&quot;
MM_redirectLoginFailed=&quot;mission.html&quot;
MM_flag=&quot;ADODB.Recordset&quot;
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_Certtest_STRING
MM_rsUser.Source = &quot;SELECT username, password&quot;
If MM_fldUserAuthorization <> &quot;&quot; Then MM_rsUser.Source = MM_rsUser.Source & &quot;,&quot; & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & &quot; FROM Table1 WHERE username='&quot; & MM_valUsername &&quot;' AND password='&quot; & CStr(Request.Form(&quot;textfield2&quot;)) & &quot;'&quot;
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open
If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
Session(&quot;MM_Username&quot;) = MM_valUsername
If (MM_fldUserAuthorization <> &quot;&quot;) Then
Session(&quot;MM_UserAuthorization&quot;) = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session(&quot;MM_UserAuthorization&quot;) = &quot;&quot;
End If
if CStr(Request.QueryString(&quot;accessdenied&quot;)) <> &quot;&quot; And false Then
MM_redirectLoginSuccess = Request.QueryString(&quot;accessdenied&quot;)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)
End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)
End If
%>
<%
var Recordset1 = Server.CreateObject(&quot;ADODB.Recordset&quot;);
Recordset1.ActiveConnection = MM_Cert_STRING;
Recordset1.Source = &quot;SELECT ID, username, password FROM Table1&quot;;
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 3;
Recordset1.LockType = 3;
Recordset1.Open();
var Recordset1_numRows = 0;
%>
<%
// *** Validate request to log in to this site.
var MM_LoginAction = Request.ServerVariables(&quot;URL&quot;);
if (Request.QueryString!=&quot;&quot;) MM_LoginAction += &quot;?&quot; + Request.QueryString;
var MM_valUsername=String(Request.Form(&quot;textfield&quot;));
if (MM_valUsername != &quot;undefined&quot;) {
var MM_fldUserAuthorization=&quot;&quot;;
var MM_redirectLoginSuccess=&quot;file:///C|/Documents and Settings/Matt JL/Desktop/Frames site/NEWFRAMES/mission.html&quot;;
var MM_redirectLoginFailed=&quot;file:///C|/Documents and Settings/Matt JL/Desktop/Frames site/NEWFRAMES/history.html&quot;;
var MM_flag=&quot;ADODB.Recordset&quot;;
var MM_rsUser = Server.CreateObject(MM_flag);
MM_rsUser.ActiveConnection = MM_Cert_STRING;
MM_rsUser.Source = &quot;SELECT username, password&quot;;
if (MM_fldUserAuthorization != &quot;&quot;) MM_rsUser.Source += &quot;,&quot; + MM_fldUserAuthorization;
MM_rsUser.Source += &quot; FROM Table1 WHERE username='&quot; + MM_valUsername + &quot;' AND password='&quot; + String(Request.Form(&quot;textfield2&quot;)) + &quot;'&quot;;
MM_rsUser.CursorType = 0;
MM_rsUser.CursorLocation = 2;
MM_rsUser.LockType = 3;
MM_rsUser.Open();
if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
// username and password match - this is a valid user
Session(&quot;MM_Username&quot;) = MM_valUsername;
if (MM_fldUserAuthorization != &quot;&quot;) {
Session(&quot;MM_UserAuthorization&quot;) = String(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value);
} else {
Session(&quot;MM_UserAuthorization&quot;) = &quot;&quot;;
}
if (String(Request.QueryString(&quot;accessdenied&quot;)) != &quot;undefined&quot; && false) {
MM_redirectLoginSuccess = Request.QueryString(&quot;accessdenied&quot;);
}
MM_rsUser.Close();
Response.Redirect(MM_redirectLoginSuccess);
}
MM_rsUser.Close();
Response.Redirect(MM_redirectLoginFailed);
}
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;<%=MM_LoginAction%>&quot;>
<input type=&quot;text&quot; name=&quot;textfield&quot;>
<input type=&quot;text&quot; name=&quot;textfield2&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</form>
</body>
</html>
<%
Recordset2.Close()
%>
<%
Recordset1.Close();
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top