Print Page | Close Window

I need help....newbie

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=10588
Printed Date: 30 March 2026 at 12:10pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: I need help....newbie
Posted By: aspidiot2
Subject: I need help....newbie
Date Posted: 24 May 2004 at 4:23pm

I am trying to do is to build a website for my Lodge. When a Lodge member logs in, I want to display the account information associated with the user name and password. I have created a login page and it seems to work. My problem is, when I login with any user name and password I can only display the first record in my database. Its porbably a simple fix, but I am new to this. I am using DreamWeaver MX and MS Access 2003. Am I missing a SQL statement or something? If so please tell what it is and on which page it belongs. Please help fix my site.

Here is the code for the login page:

<mailto:%@LANGUAGE="VBSCRIPT'>%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/registration.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_registration_STRING
Recordset1.Source = "SELECT * FROM registration"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Request.QueryString
MM_valUsername=CStr(Request.Form("UserName"))
If MM_valUsername <> "" Then
  MM_fldUserAuthorization="AccessPriviledge"
  MM_redirectLoginSuccess="restricted/results.asp"
  MM_redirectLoginFailed="www/Master-Mason.htm"
  MM_flag="ADODB.Recordset"
  set MM_rsUser = Server.CreateObject(MM_flag)
  MM_rsUser.ActiveConnection = MM_registration_STRING
  MM_rsUser.Source = "SELECT UserName, UserPass"
  If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
  MM_rsUser.Source = MM_rsUser.Source & " FROM registration WHERE UserName='" & Replace(MM_valUsername,"'","''") &"' AND UserPass='" & Replace(Request.Form("UserPass"),"'","''") & "'"
  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("MM_Username") = MM_valUsername
    If (MM_fldUserAuthorization <> "") Then
      Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
    Else
      Session("MM_UserAuthorization") = ""
    End If
    if CStr(Request.QueryString("accessdenied")) <> "" And false Then
      MM_redirectLoginSuccess = Request.QueryString("accessdenied")
    End If
    MM_rsUser.Close
    Response.Redirect(MM_redirectLoginSuccess)
  End If
  MM_rsUser.Close
  Response.Redirect(MM_redirectLoginFailed)
End If
%>

Here is the code for my results page:

<mailto:%@LANGUAGE="VBSCRIPT'>%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' *** Logout the current user.
MM_Logout = CStr(Request.ServerVariables("URL")) & "?MM_Logoutnow=1"
If (CStr(Request("MM_Logoutnow")) = "1") Then
  Session.Contents.Remove("MM_Username")
  Session.Contents.Remove("MM_UserAuthorization")
  MM_logoutRedirectPage = "../Master-Mason.htm"
  ' redirect with URL parameters (remove the "MM_Logoutnow" query param).
  if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage = CStr(Request.ServerVariables("URL"))
  If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
    MM_newQS = "?"
    For Each Item In Request.QueryString
      If (Item <> "MM_Logoutnow") Then
        If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"
        MM_newQS = MM_newQS & Item & "=" & Server.URLencode(Request.QueryString(Item))
      End If
    Next
    if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage & MM_newQS
  End If
  Response.Redirect(MM_logoutRedirectPage)
End If
%>
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers="member"
MM_authFailedURL="../Master-Mason.htm"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
  If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization")) >=1) Then
    MM_grantAccess = true
  End If
End If
If Not MM_grantAccess Then
  MM_qsChar = "?"
  If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
  MM_referrer = Request.ServerVariables("URL")
  if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
  MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
  Response.Redirect(MM_authFailedURL)
End If
%>
<!--#include file="../../Connections/registration.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_registration_STRING
Recordset1.Source = "SELECT * FROM registration"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Recordset2__MMColParam
Recordset2__MMColParam = "1"
If (Request.QueryString("ID") <> "") Then
  Recordset2__MMColParam = Request.QueryString("ID")
End If
%>
<%
Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_registration_STRING
Recordset2.Source = "SELECT * FROM registration WHERE ID = " + Replace(Recordset2__MMColParam, "'", "''") + ""
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()

Recordset2_numRows = 0
%>
<%
Dim MM_paramName
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth

Dim MM_removeList
Dim MM_item
Dim MM_nextItem

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
  MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If

MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_k

-------------
Did I do that?




Replies:
Posted By: Semikolon
Date Posted: 24 May 2004 at 5:11pm
sorry, but drop the dreamweaver code and write the code yourself.

you can start with the tutorials and sample applications on this site and ask for help here if you are stuck and we will help you the best we can. just don't come with generated code like this! PLEASE!


Welcome to the forums BTW


Posted By: Gullanian
Date Posted: 24 May 2004 at 6:08pm
Hmmmm very complicated code, that could be simplified a lot.  Make sure you got all your WHERES in.  If you want to display multiple records make sure you do a recordset loop (EG DO UNTIL recordSET.EOF)


Posted By: KCWebMonkey
Date Posted: 25 May 2004 at 1:37pm
hmm... i don't know which is worse... the fact that you are using dreamweaver code, or the fact that you had to register as "aspidiot2" because there was already an "aspidiot" registered...


Posted By: michael
Date Posted: 27 May 2004 at 11:14pm
LOL

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: MurrayNeill
Date Posted: 05 July 2004 at 11:10pm

First of all I am surprised at the elitist attitude you have encountered here.  So your new to this and your using DW code... so what guys? we've all got to start somewhere.

It seems to me your problem is a fairly simple one that I remember encountering myself when I was learning. All you're missing is a parameter to tell your page what record to select. By default it will display the first record. You need to add a filter to select the record of the logged in user. To do this simply add a filter to your recordset that will select the record where the username field = the session variable MM_username.



Posted By: Semikolon
Date Posted: 06 July 2004 at 2:42pm
Generated code like that is not the place to start AT ALL!

The code looks like crap and it's almost unable to read and edit it. Much of it could also have been done better with half the code..

Also when generating code like that, you have no chances of learning something of it, as you can't read and understand sh*t of it when you are a newbie, and, if you are one of the few newbies who actually may understand it, you would just teach yourself bad code practices..


Posted By: MurrayNeill
Date Posted: 06 July 2004 at 4:34pm
I agree it is not the best code and probably not the best way to learn.  However the guy is obviously not a professional and just wants to get his site up and running. Hes not trying out for asp coder of the year.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net