CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 users can access to specific records only

Print topic Send  topic

Author Message
SteveS

Posts: 41
Posted: 01/31/2005, 5:50 AM

Hi,

I have a table with a primary key called 'user_id' along with fields called name, password, address etc.

When a user logs on they goto a menu screen. One of the options on the menu is to edit their personal details.

I would like a link that redirects them to their update form only (as opposed to another users).

Ie bob logs in, his 'user_id'=15. When he views his personal info it takes him to personal.asp?user_id=15

Can someone help please with adding code to extract the user_id based on log in name and then add this to a link?

Thank you for any help.

Regards,

SteveS
View profile  Send private message
Nicole

Posts: 586
Posted: 01/31/2005, 6:14 AM

SteveS,
When user logs in his user_id is stored in a session variable UserID (by default). So there’s no need to pass user id via URL, you can retrieve it from session in WHERE parameter settings.
Sample settings for WHERE parameter
Field
Name: user_id_field_name
Type: Integer (usually)
Condition: equals(=)
Parameter Source
Name: CCGetUserID
Type: Expression


_________________
Regards,
Nicole
View profile  Send private message
SteveS

Posts: 41
Posted: 01/31/2005, 6:26 AM

Nicole, thanks for your help.

How would your info link into my menu system though?

All logged in users get a menu. The menu is a group of links that reference different urls.

Thanks,

SteveS
View profile  Send private message
Nicole

Posts: 586
Posted: 01/31/2005, 6:32 AM

There’s just no need to add user id to url. Instead of using
Personal.asp?user_id=15
You can use Personal.asp, that is more secure.

_________________
Regards,
Nicole
View profile  Send private message
SteveS

Posts: 41
Posted: 01/31/2005, 6:50 AM

Hi Nicole, you have lost me now. How would I make one of the menu links point to the right record using this?

Lets say User_ID=15 which is bob's id. He gets his menu and when he clicks the 'edit personal info' bit it links to the correct page... how?

Sorry if I sound a little daft, I can't get my head around it.

SteveS
View profile  Send private message
peterr


Posts: 5971
Posted: 01/31/2005, 11:55 AM

Steve,

Well, you wrote in your first posting that you need help with "adding code to extract the user_id based on log in name and then add this to a link". Sorry, does it mean that you also need help with creating links in CCS? You can just click on the "Add Link" icon in the Toolbox (Forms tab).
Then in Href Source property you would select the page that you want to point to.
There is no need for user_id as Nicole explained.
The record shouldn't be based on the URL, only on the CCGetUserID expression as Nicole wrote above.

In other words: why extract the user_id before creating the link, instead of after the user already comes to the record page? This is what CCGetUserID does - it extracts the user_id so that only the record for the current user is shown, without any URL parameters. The same can be done by configuring the WHERE parameter to use UserID session. See http://forums.codecharge.com/posts.php?post_id=47712
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Benjamin Krajmalnik
Posted: 01/31/2005, 12:39 PM

Call the form without any parameters.
On the datasource, set your where expression to use CCGetUserID().
That way, the info will be retrieved properly without the ability for
someone to hijack your data.

"SteveS" <SteveS@forum.codecharge> wrote in message
news:641fe45ab1b692@news.codecharge.com...
> Hi Nicole, you have lost me now. How would I make one of the menu links
point
> to the right record using this?
>
> Lets say User_ID=15 which is bob's id. He gets his menu and when he
clicks the
> 'edit personal info' bit it links to the correct page... how?
>
> Sorry if I sound a little daft, I can't get my head around it.
>
> SteveS
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

SteveS

Posts: 41
Posted: 01/31/2005, 12:52 PM

Hi, problem solved.

THANKS TO ALL FOR YOUR SUGGESTIONS,

I couldn't understand how to make this work and then bang!! I got it!!

I have included my logic for anyone who thinks like me and is still stuck.

I wasn't sure what the "proper" solution was, hence why my questions seemed to vary.

As you say in your last paragraph Peter (and for the benefit of all others looking for a solution) -

Send your logged in user to the edit page of a record - to specify that they only see their record(s) select the form then the properties window | data tab and click the '...' on the data source row. It is here that you specifiy the contents of the form. Select the appropiate field and parameter source and off you go!

To return the record of a person based on their log in name my data was:

Field name=Name (my colomn heading)
Condition=equals
Parameter Source: userlogin (session variable)
Type: Session (to ensure it looks up the session variable)

In my case this returns the form filled in with data that reflects the logged in user, hey, it works!

Cheers to all!

SteveS
View profile  Send private message
Benjamin Krajmalnik
Posted: 01/31/2005, 1:18 PM

Only one suggestion.
Instead of using the session variable directly, use an expression calling
CCGetUserID().

The reason for this is simple - if you end up changing the session variable
names (as I have had to do due to apps which can run concurrently and need
separate access rights for a user) youwill not have to recode.


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.