This topic is locked

Auto add in User Info

6/15/2008 6:10:45 PM
PHPRunner General questions
T
thebwit author

Ok I just realized the permissions for different groups and what not. Very cool.
Anyways, that now leads me to a problem I can't figure out:
I have a table pages with the following fields:

pid

page_name

page_txt

uid

tstamp
Now I want which ever user is logged in to have their uid auto filled into the uid when someone adds or edits a page. I do not want them to have the ability to change this at all.
I know there has to be a way to do this and even if they can't do it that way - what about limited a select field to be only their own user info?
I hope this makes sense

J
Jane 6/17/2008

Hi,
I see what you're saying.

Set up this field as readonly on the "Edit as" settings dialog, use $_SESSION["uid"] as default value and check off Apply on the Edit page as well option.

To fill $_SESSION["uid"] variable use AfterSuccessfulLogin event on the Events tab:

global $conn;

$rs = db_query("select user_id from users_table where user_name='".$_SESSION["UserID"]."'",$conn);

$data = db_fetch_array($rs);

$_SSSION["uid"] = $data["user_id"];



where user_id, user_name are your actual field names, users_table is your actual table name.

T
thebwit author 6/18/2008

Hi,

I see what you're saying.

Set up this field as readonly on the "Edit as" settings dialog, use $_SESSION["uid"] as default value and check off Apply on the Edit page as well option.

To fill $_SESSION["uid"] variable use AfterSuccessfulLogin event on the Events tab:
where user_id, user_name are your actual field names, users_table is your actual table name.


Thanks so much that worked!

W
wypman 6/20/2008

I have been looking at this too. It only shows the User instead of there name when you show the record though. Is there a way of displaying the name?
I managed to do it with a lookup table - but that only worked on the add page - and when you viewd the record it showed the userid again and not there name.

J
Jane 6/23/2008

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.