twidget26
12-19-2006, 01:33 PM
I am redesigning our company website and am having issues with how to log in users with levels to different pages. Example: Level "A" goes to a_summary.asp and level "M" goes to m_summary.asp. I am currently using Dreamweaver's "helpers" for most of it because I have a tight deadline. In the past we had an outside source do the database portion of our website and now I am trying to take over that area. He used VBScript, so I plan on using the same thing - but I am more familiar with JavaScript. Below is the code that I have, but I need it to redirect to the above mentioned pages:
<!--#include file="../Connections/connTBGMNWeb.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername = CStr(Request.Form("username"))
If MM_valUsername <> "" Then
Dim MM_fldUserAuthorization
Dim MM_redirectLoginSuccess
Dim MM_redirectLoginFailed
Dim MM_loginSQL
Dim MM_rsUser
Dim MM_rsUser_cmd
MM_fldUserAuthorization = "AgentOrMember"
MM_redirectLoginSuccess = "../login/login.asp"
MM_redirectLoginFailed = "../login/login_bad.asp"
MM_loginSQL = "SELECT AgencyID, PW"
If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
MM_loginSQL = MM_loginSQL & " FROM dbo.[User] WHERE AgencyID = ? AND PW = ?"
Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
MM_rsUser_cmd.ActiveConnection = MM_connTBGMNWeb_STRING
MM_rsUser_cmd.CommandText = MM_loginSQL
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 255, MM_valUsername) ' adVarChar
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 255, Request.Form("password")) ' adVarChar
MM_rsUser_cmd.Prepared = true
Set MM_rsUser = MM_rsUser_cmd.Execute
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
%>
The old code looked like this (but I am using different db connections and record sets now):
<!--#include file="conn.asp"-->
<%
If Request.Form("username")<>"" Then
' Code to open connection to Access DSN
sql="SELECT * FROM [User] WHERE AgencyID='" & Request.Form("username") & "'"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, cn, 3, 3
If rs.EOF Then
Response.Redirect "login/login_bad.asp"
End If
If rs.Fields("PW")<>Request.Form("Password") Then
Response.Redirect "login/login_bad.asp"
End If
Session("PWD")=rs.Fields("PW")
Session("AgencyID")=rs.Fields("AgencyID")
Session("Level")=rs.Fields("Level")
Session("AgencyName")=rs.Fields("AgencyName")
Session("MemberID")=rs.Fields("AgencyID")
Session("AgentOrMember")=rs.Fields("AgentOrMember")
If Session("AgentOrMember")="A" Then Response.Redirect "login/agent/a_summary.asp"
If Session("AgentOrMember")="M" Then Response.Redirect "login/member/m_summary.asp"
End If
%>
Any help is appreciated!
Twidget26
<!--#include file="../Connections/connTBGMNWeb.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername = CStr(Request.Form("username"))
If MM_valUsername <> "" Then
Dim MM_fldUserAuthorization
Dim MM_redirectLoginSuccess
Dim MM_redirectLoginFailed
Dim MM_loginSQL
Dim MM_rsUser
Dim MM_rsUser_cmd
MM_fldUserAuthorization = "AgentOrMember"
MM_redirectLoginSuccess = "../login/login.asp"
MM_redirectLoginFailed = "../login/login_bad.asp"
MM_loginSQL = "SELECT AgencyID, PW"
If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
MM_loginSQL = MM_loginSQL & " FROM dbo.[User] WHERE AgencyID = ? AND PW = ?"
Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
MM_rsUser_cmd.ActiveConnection = MM_connTBGMNWeb_STRING
MM_rsUser_cmd.CommandText = MM_loginSQL
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 255, MM_valUsername) ' adVarChar
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 255, Request.Form("password")) ' adVarChar
MM_rsUser_cmd.Prepared = true
Set MM_rsUser = MM_rsUser_cmd.Execute
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
%>
The old code looked like this (but I am using different db connections and record sets now):
<!--#include file="conn.asp"-->
<%
If Request.Form("username")<>"" Then
' Code to open connection to Access DSN
sql="SELECT * FROM [User] WHERE AgencyID='" & Request.Form("username") & "'"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, cn, 3, 3
If rs.EOF Then
Response.Redirect "login/login_bad.asp"
End If
If rs.Fields("PW")<>Request.Form("Password") Then
Response.Redirect "login/login_bad.asp"
End If
Session("PWD")=rs.Fields("PW")
Session("AgencyID")=rs.Fields("AgencyID")
Session("Level")=rs.Fields("Level")
Session("AgencyName")=rs.Fields("AgencyName")
Session("MemberID")=rs.Fields("AgencyID")
Session("AgentOrMember")=rs.Fields("AgentOrMember")
If Session("AgentOrMember")="A" Then Response.Redirect "login/agent/a_summary.asp"
If Session("AgentOrMember")="M" Then Response.Redirect "login/member/m_summary.asp"
End If
%>
Any help is appreciated!
Twidget26