From: RGolfer on
Hi There, Hopeing for some direction here. What I am trying to do is have one
login page that basically looks at several tables. The next page uses a SHOW IF
variable if the username and password actually shows up in one of the tables.
The most common fields are email_address and password so I have used them. How
do I have the DW login function look at multiple tables. Is it an AND
connection or an OR or soemthing else. I have tried these with bad results.
Here is the code:

' *** 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("user_Race"))
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 = ""
MM_redirectLoginSuccess = "enter.asp"
MM_redirectLoginFailed = "LoginMainRR.asp"

MM_loginSQL = "SELECT Email_Address, Password"
If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," &
MM_fldUserAuthorization
MM_loginSQL = MM_loginSQL & " FROM RACING_REG AND DRIFT_REG AND OFFROAD_REG
AND STREET_REG WHERE Email_Address = ? AND Password = ?"
Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
MM_rsUser_cmd.ActiveConnection = MM_toyoracer_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("pass_race")) ' 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
%>

Any direction here would be appreciated .. either an answer or pointed to an
article someplace.

From: bregent on
You need to join the two tables and return all of the fields you want to check
in your SQL statement. I would suggest learning some basic SQL before going any
further.
http://www.w3schools.com/sql/default.asp

From: RGolfer on
Hi Bregent,

I have looked at the SQL statements and that is where I am getting confused.
Sorry! I had a look at other tables that I had joined in the past ... that is
the problem when you are a sporadic web designer, there is always the
re-learning curve, and as per teh SQL site to simply read from multiple tables
I should be able to use a coma to include them.

Am I closer with this statement?

MM_loginSQL = MM_loginSQL & " FROM RACING_REG, DRIFT_REG, STREET_REG,
OFFROAD_REG WHERE RACING_REG.Email_Address OR DRIFT_REG.Email_Address OR
STREET_REG.Email_Address OR OFFROAD_REG.Email_Address = ? AND
RACING_REG.Password OR DRIFT_REG.Password OR STREET_REG.Password OR
OFFROAD_REG.Password = ?"

From: bregent on
>Am I closer with this statement?

No, not really. Before testing the columns in the where clause, you need to
join the related tables. This can be done in either the From clause or the
Where clause depending on your DBMS. What database are you running? What is
(are) the related column(s) in the tables?

From: RGolfer on
That sounds too simple! Now I created the query and that works fine. I go to DW
and try using the Login In User behaviour and I dont see teh name of the Query.
I create a recordset and it shows the table. I will try just typing in the
Query name to see if it recognizes it.

 |  Next  |  Last
Pages: 1 2
Prev: Doc window gray space
Next: web site evaluation