Link to home
Start Free TrialLog in
Avatar of mrwebdev
mrwebdev

asked on

ASP - MDB Login with a Twist?

Microsoft (MDB) Login validation.

Form login:

ASP question, How would you validate a Member & Password form fields in a Form named "login" to make sure they exist and match in a table, and if so, then pass another field (MailingListID) in that same table row to a string receiving ASP page to show that users data from that entire row.

------------------------------------------------------------------------------------------------------
I am currently using (<%=MM_LoginAction%>) for the action, a Macromedia extension
concidering using a custom script on ("member-update-now.asp" or "member-login.asp").


<form method="POST" action=" " name="LogIn">
Member Log In
Member : <input type="TEXT" name="Member" size="20">
Password: <input type="PASSWORD" name="Password" size="20">                
<input name="login" type="submit" value="Submit Login">
</form>

Redirect if success: member-update-now.asp
Redirect if failed: member-signup.asp or possibly self (member-login.asp)
-------------------------------------------------------------------------------------------------------

Thanks in advance... please smart@sses need not reply!
ASKER CERTIFIED SOLUTION
Avatar of dc_cypher
dc_cypher

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrwebdev
mrwebdev

ASKER

Although I didnt use your answer it was a great response. I  changed the following code and it works like a charm. I am posting this so that it may help others.

<%
' *** 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("Member"))
If MM_valUsername <> "" Then
  MM_fldDynamicRedirect="MailingListID"
  MM_fldUserAuthorization=""
  MM_redirectLoginSuccessDynamic=""
  MM_redirectLoginFailed="member-signup.asp"
  MM_flag="ADODB.Recordset"
  set MM_rsUser = Server.CreateObject(MM_flag)
  MM_rsUser.ActiveConnection = MM_my_STRING
  MM_rsUser.Source = "SELECT member, password"
  If MM_fldDynamicRedirect <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldDynamicRedirect
  If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
  MM_rsUser.Source = MM_rsUser.Source & " FROM members WHERE member='" & Replace(MM_valUsername,"'","''") &"' AND password='" & Replace(Request.Form("Password"),"'","''") & "'"
  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)
    ElseIf (MM_fldDynamicRedirect <> "") Then

'---------My Modifications---------note: --["member-account-detail.asp?MailingListID=" + ]---

      MM_redirectLoginSuccessDynamic = "member-account-detail.asp?MailingListID=" + CStr(MM_rsUser.Fields.Item(MM_fldDynamicRedirect).Value)

'-----------------------------------------------------------------------------------------

    Else
      Session("MM_UserAuthorization") = ""
    End If
    if CStr(Request.QueryString("accessdenied")) <> "" And false Then
      MM_redirectLoginSuccessDynamic = Request.QueryString("accessdenied")
    End If
    MM_rsUser.Close
    Response.Redirect(MM_redirectLoginSuccessDynamic)
  End If
  MM_rsUser.Close
  Response.Redirect(MM_redirectLoginFailed)
End If
%>

This is a modified version of Login redirect to a URL in a databse extension from Macromedia's Exchange.
PS:  Instead of using the URL field I used the MailingListID field.