Forums

This topic is locked

Dreamweaver 8 Log in behaviour problem

Posted 08 Apr 2007 17:42:11
1
has voted
08 Apr 2007 17:42:11 Tom Bathgate posted:
Hey All,

I have a problem here. I am using the dw8 log in behavior for my site and it works fines. But it only retrieves the customer's username and password in the record set, but I want it to retrieve the customers ID and store it in a session variable called CustomerID that i can then call and use in other parts of the site. I've tried the following code but it just doesn't seem to work:

<pre id=code><font face=courier size=2 id=code>
&lt;%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL"
If Request.QueryString &lt;&gt; "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername = CStr(Request.Form("userName")
If MM_valUsername &lt;&gt; "" Then
Dim MM_fldUserAuthorization
Dim MM_redirectLoginSuccess
Dim MM_redirectLoginFailed
Dim MM_loginSQL
Dim MM_rsUser
Dim MM_rsUser_cmd

MM_fldUserAuthorization = ""
MM_redirectLoginSuccess = "default.asp"
MM_redirectLoginFailed = "loginfailed.asp"

MM_loginSQL = "SELECT EmailAddress, Password, ID"
If MM_fldUserAuthorization &lt;&gt; "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
MM_loginSQL = MM_loginSQL & " FROM Customer WHERE EmailAddress = ? AND Password = ?"
Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command"
MM_rsUser_cmd.ActiveConnection = MM_ArtemisGems_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, 50, 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
Session("CustomerID" = ID
If (MM_fldUserAuthorization &lt;&gt; "" Then
Session("MM_UserAuthorization" = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session("MM_UserAuthorization" = ""
End If
if CStr(Request.QueryString("accessdenied") &lt;&gt; "" And true 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
%&gt;

</font id=code></pre id=code>

Can anyone point me in the right direction of this.

Thaks guys!!!

Tom

Replies

Replied 15 Apr 2007 15:02:28
15 Apr 2007 15:02:28 Kenneth Halley replied:
I don't even know what scripting language this is- only do php myself but have done the same thing you are trying to do and it works fine.

Bear in mind my non knowledge of the language but I reckon you need to set up the variable "ID" before you set it in to the session.
These two lines seem to do the same for the other parameters you pulled out in the recordset, I think you might need to do the same for your parameter- ID

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, 50, Request.Form("password") ' adVarChar
at a total guess add:
MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param3", 200, 1, 50, Request.Form("ID") ' adVarChar

-----------------------------------
www.halleynet.co.uk

Reply to this topic