edmorales
|
| Posted: 01/30/2003, 12:25 PM |
|
hello!
how i can pass the userID from the data base to other form after login action.
thank you
|
|
|
 |
Edd
|
| Posted: 01/30/2003, 1:11 PM |
|
The login form sets session variables (look at your project properties) and call those to populate your form, ie create a before show event.
Hope this helps.
Edd
|
|
|
 |
Michael Mikkelsen
|
| Posted: 01/30/2003, 1:34 PM |
|
There are several ways to do this. I'll give you an example from the program that I am working on.
In my program the username needs to be a Database column, so that when the user logs in and then adds a record to the database his username is one of the fields of that record. I added a Hidden Field to my Record Form and Under Properties - Data - make sure the Source Type is Database Column and set the Control Source to the username column in your database.
Under events for the Hidden Field add code to the before show event. Here is was the code should look like:
global $time_card3;
$time_card3->username->SetValue( CCgetuserLogin() );
in this example the Record Form is called time_card3 and the Hidden Field is called username.
Note: You may not need to actually pass the username in through a Form. For example if you have a Grid and you are wanting to only show records that contain the users userID. Because session variables are available on every page once the user is logged in you can easily use them as part of your query.
Here is how you do it. Looks at the Properties of your Grid under the Data tab. Your Source Type should be Table, for the Data Source click on the "..." button. Click on the "+" to add a table parameter. Select the Field name of the username field in your database, Type should be Text. Condition is equals(=). Change the Parameter Source to UserLogin, and the Type to Session.
That's it. No Custom code for that one.
Hope that answered all your questions.
Michael Mikkelsen
|
|
|
 |
Michael Mikkelsen
|
| Posted: 01/30/2003, 7:42 PM |
|
I just found an easier way than my example above which uses custom code.
Instead of creating a hidden field and populating it in custom code, you don't even need to use custom code at all.
Look at the Properties of the Record Form, under the Data tab set the Custom Insert Type to Table and click the "..." button for Custom Incert. From there instead of using the hidden field as the Parameter Source use the UserLogin Session Variable. So Field Name is the username field in your datebase, Field Type is Text, Parameter source name is UserLogin, Parameter source type is Session.
So there it is, it's always better when it's built in to CCS but you just have to find it.
Michael Mikkelsen
mike.m@pobox.com
|
|
|
 |
lneisius
|
| Posted: 01/31/2003, 4:43 AM |
|
Michael Mikkelsen: Instead of creating the before show of the hidden field I use the default value in the properties manager and just add the ccs function in there. This makes the pages more transportable between languages!!!
ie. I have a similar form for posting info to a page and a hidden field named userid in the default I type in Session("UserLogin") or CCGetUserLogin() or any of the built in functions. Hope this helps!
|
|
|
 |
|