Skip to main content
April 9, 2007
Answered

userID

  • April 9, 2007
  • 5 replies
  • 663 views
If you have ever let Dreamweaver create a login for you with user access level it seems quite easy especially when you are checking the access level through your MySQL database. One of the issues I am running accross is, I want users to login but also able to change their username, password, first name, last name, e-mail and so forth and I just don't know where to start. I am using Dreamweaver's MX 2004 login function with Access Level. So the code it generates is basically what I have. So how do I get the user to edit their own info. Each user has their own userID. So how can I grab the userID once they logged in when they are in the index.php page. The index.php is when the user successfully log's in.
The only thing I see in the login which Dreamweaver places these php scripts is MM_Username & MM_UserGroup.
I hope I am making sense and not confusing anyone.

Thank you,
AdonaiEchad
This topic has been closed for replies.
Correct answer Newsgroup_User
AdonaiEchad wrote:
> Is the record set supposed to be as follows...
>
> SELECT *
> FROM myusers
> WHERE myusers.userID = "$_SESSION['userID']"

There are several things wrong with that query. First of all, you cannot
put an array element, such as $_SESSION['userID'] in double quotes.
Second, the whole query will be surrounded in double quotes by
Dreamweaver, so you have a conflict of quotes. Third, userID will be a
number, so it shouldn't be in quotes anyway.

When building a query like this in Dreamweaver, use the Recordset dialog
box to define the variable, and select Number as the data type.

Most important of all, where are you going to get $_SESSION['userID']
from in the first place?

Create a recordset called getID, and use the following SQL:

SELECT userID FROM myusers
WHERE username = var1

In the Variables field, define var1 as $_SESSION['MM_Username'], and set
its data type to text.

You can then create $_SESSION['userID'] like this (put it after the
recorset code):

$_SESSION['userID'] = $row_getID['userID'];

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

5 replies

April 10, 2007
I am running Dreamweaver MX 2004.

I made the proper changes and now the page does now work.

So the next step is as you stated...
"You can then create $_SESSION['userID'] like this (put it after the
recorset code):

$_SESSION['userID'] = $row_getID['userID'];"

For the $_SESSION['userID'] I went to bindings panel and clicked on the plus sign and selected "session variable", in there I placed userID in the field box and it created for me the $_SESSION['userID']. Hopefully this is correct.

For the next step $_SESSION['userID'] = $row_getID['userID']; I am not sure how I am supposed to do this, is this statement in the same SQL statement I done for...
SELECT userID FROM myusers
WHERE username = 'var1'


April 12, 2007
How do I incorporate the next step David,

$_SESSION['userID'] = $row_getID['userID']; I am not sure how I am supposed to do this, is this statement in the same SQL statement I done for...
SELECT userID FROM myusers
WHERE username = 'var1'

I'm not sure about this section.
Inspiring
April 10, 2007
AdonaiEchad wrote:
> That's the thing, I do not know how to get the $_SESSION['userID'].
>
> I have placed the following statement.
> SELECT userID FROM myusers
> WHERE username = var1
>
> Then I placed in the variables in the Recordset Add Parameters as such.
> Name: var1
> Defualt value: -1
> Runtime value: $_SESSION['MM_Username']
>
> When I click on a link like Edit Profile and it goes to the page called
> edituser.php I receive the following error.
> Unknown column 'david' in 'where clause'

Which version of Dreamweaver are you running? In DW 8.0.2, set the Data
type for var1 to "Text". If you're running an earlier version of
Dreamweaver, change the SQL to this:

SELECT userID FROM myusers
WHERE username = 'var1'

In other words, put single quotes around var1.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
April 9, 2007
That's the thing, I do not know how to get the $_SESSION['userID'].

I have placed the following statement.
SELECT userID FROM myusers
WHERE username = var1

Then I placed in the variables in the Recordset Add Parameters as such.
Name: var1
Defualt value: -1
Runtime value: $_SESSION['MM_Username']

When I click on a link like Edit Profile and it goes to the page called edituser.php I receive the following error.
Unknown column 'david' in 'where clause'

I know in ColdFusion there is a function called #GetAuthUser()# so the SQL statement would look something like this but I do not know if it is the same for PHP.

SELECT userID FROM myusers
WHERE userID = '#GetAuthUser()#'

Inspiring
April 9, 2007
AdonaiEchad wrote:
> So how can I grab the userID once they
> logged in when they are in the index.php page. The index.php is when the user
> successfully log's in.
> The only thing I see in the login which Dreamweaver places these php scripts
> is MM_Username & MM_UserGroup.

After a person has logged in, you know the username from
$_SESSION['MM_Username']. Use that to create a recordset to select the
userID, and set the filter as Session Variable MM_Username.

Since the Dreamweaver Restrict Access to Page server behavior relies on
$_SESSION['MM_Username'], you should get the user to log out and log
back in again after changing the username.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Newsgroup_UserCorrect answer
Inspiring
April 9, 2007
AdonaiEchad wrote:
> Is the record set supposed to be as follows...
>
> SELECT *
> FROM myusers
> WHERE myusers.userID = "$_SESSION['userID']"

There are several things wrong with that query. First of all, you cannot
put an array element, such as $_SESSION['userID'] in double quotes.
Second, the whole query will be surrounded in double quotes by
Dreamweaver, so you have a conflict of quotes. Third, userID will be a
number, so it shouldn't be in quotes anyway.

When building a query like this in Dreamweaver, use the Recordset dialog
box to define the variable, and select Number as the data type.

Most important of all, where are you going to get $_SESSION['userID']
from in the first place?

Create a recordset called getID, and use the following SQL:

SELECT userID FROM myusers
WHERE username = var1

In the Variables field, define var1 as $_SESSION['MM_Username'], and set
its data type to text.

You can then create $_SESSION['userID'] like this (put it after the
recorset code):

$_SESSION['userID'] = $row_getID['userID'];

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Inspiring
April 9, 2007
You would have to create a data bound form which is filtered by the userID. Then you can use the update server behavior to let the user update their info.