HI guys,
Im trying to catch the actual unique ID of the entry taking place when a user registers on my site, then populate a second table with that value.
As in Author_ID = 75 > then ad 75 within the 'peoples' table as UserID.
Now Ive been using this bit of code and I thought It was working ok, however I have recently discovered since upgrading to sql server 8.0 that my value of user_id is null.
Could someone help me out with this? I desperately need to catch the unique ID of the entry taking place!
'******************************************
'*** Update datbase ***
'******************************************
'If this is new reg and the username and email is OK or this is an update then register the new user or update the rs
If (strMode = "new" AND blnUsernameOK AND blnEmailOK AND blnSecurityCodeOK AND blnEmailBlocked = False) OR (strMode = "update" AND blnConfirmPassOK) Then
'If this is new then create a new rs and reset session variable
If strMode = "new" Then
Session("lngSecurityCode") = null
rsCommon.AddNew
End If
'Insert the user's details into the rs
With rsCommon
&nbs p;
If strMode = "new" Then .Fields("Username") = strUsername
If strMode = "new" Then .Fields("Group_ID") = intForumStartingGroup
&nbs p;
'If part number = 0 (all) or part 1 (reg details) then run this code
If intUpdatePartNumber = 0 OR intUpdatePartNumber = 1 Then
&nbs p;
If (strMode = "update" AND blnPasswordChange = True) OR strMode = "new" Then .Fields("Password") = strEncryptedPassword
If (strMode = "update" AND blnPasswordChange = True) OR strMode = "new" Then .Fields("Salt") = strSalt
.Fields("User_code") = strUserCode
.Fields("Author_email") = strEmail
.Fields("firstname") = strFirstname
.Fields("lastname") = strLastname
'GET THE USERS AUTHOR_ID NUMBER
user_id = rsCommon("Author_ID") *doesnt appear to work??????
End If
I then use it later do to the following - however this fails as I have no value for user_id
'ADD TO THE PEOPLES TABLE
Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * From people;"
objRS.MaxRecords = 1
objRS.CursorType = 2
objRS.LockType = 3
objRS.Open strSQL, adoCon
objRS.AddNew
objRS.Fields("userID") = user_id
objRS.Fields("firstname") = strFirstname
objRS.Fields("lastname") = strLastname
objRS.Update
objRS.Close
Set objRS = Nothing
'CREATE USERS PHOTO ALBUM FOLDER
set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(Server.MapPath(strPath) & "/" & user_id) then
objFSO.CreateFolder Server.MapPath(strPath) & "/" & user_id
end if
Set objFSO = nothing
Thanks,
John