This topic is locked

Fill out field with user active

5/9/2011 11:12:04 AM
PHPRunner General questions
U
unsearcheable author

Hello.

I have a table with users and their login, and want to place in order request the user that made it automatically instead of selecting im manually.
Regards.

N
nti 5/9/2011

Your question is too vague. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=58193&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

U
unsearcheable author 5/9/2011



Your question is too vague. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=58198&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />


Eheh, i will try to refrase it (and sorry for my bad English).
When i login with certain user (thru PHPRunner login system), i want that user to be assigned to each record added.

I alredy have a table for users, and now i have to manually indicate what user is inserting the record, but offcorse this is fail because i can choose whatever user i want.

My intention is that if i login with user "John", the records that i add will have field User automatically filled with "John".
Hope its readable this time.

N
nti 5/9/2011

Maybe to do something like you describe is to have a field in the table like: Editor

  1. Remove this field from Edit and Add to make it hidden. (Choose Fields)
  2. Before Record Added and Before Record Updated
    I place something like: $values["Editor"] = $_SESSION["UserID"];
  3. Then assign login user to utilize/see his records which has the proper User ID = Editor
    I do not know exactly, I am guessing.
    Hopefully we will get additional replies. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=58208&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />

Sergey Kornilov admin 5/10/2011

The simplest way is to set default value of the field in question to $_SESSION["UserID"]
The following will work as well in events like BeforeAdd/BeforeEdit:

$values["Editor"] = $_SESSION["UserID"];
U
unsearcheable author 5/10/2011



The simplest way is to set default value of the field in question to $_SESSION["UserID"]
The following will work as well in events like BeforeAdd/BeforeEdit:

$values["Editor"] = $_SESSION["UserID"];



It seems very simple solution, but i understand that "UserID" is id of users table, and what !Editor" is ?

N
nti 5/10/2011

what !Editor" is ?


Editor is the NAME of MYFIELD wich I use in MY TABLES.
I create TABLES and have a FIELD/COL called Editor.
I also use FIELDS called: EditDT and Editip.
I utilize the following code to capture the UserID, Users IP Address and Edit DateTime.



// Get Remote Address for Edit IP

$values["Edit_Ip"] = $_SERVER["REMOTE_ADDR"];

// Get Editor's User Name

$values["Editor"] = $_SESSION["UserID"];

// Get Date and Time into Edit DT field

// TABLENAME = your TABLE NAME

$sql = "INSERT INTO tblTABLENAME(EditDT) values (now())'";


You most likely know this stuff anyway, I threw it in hoping it might help explain my other suggestions.

U
unsearcheable author 5/16/2011



Editor is the NAME of MYFIELD wich I use in MY TABLES.
I create TABLES and have a FIELD/COL called Editor.
I also use FIELDS called: EditDT and Editip.
I utilize the following code to capture the UserID, Users IP Address and Edit DateTime.



// Get Remote Address for Edit IP

$values["Edit_Ip"] = $_SERVER["REMOTE_ADDR"];

// Get Editor's User Name

$values["Editor"] = $_SESSION["UserID"];

// Get Date and Time into Edit DT field

// TABLENAME = your TABLE NAME

$sql = "INSERT INTO tblTABLENAME(EditDT) values (now())'";


You most likely know this stuff anyway, I threw it in hoping it might help explain my other suggestions.


So i don't need to alter that code to my project ? Just copy paste into event ?

U
unsearcheable author 5/29/2011

Ok, alredy pulled it off, but chaging Lookup Table to ReadOnly i loose user name that is in another table..

How can i have user filled out automatic and apearing user name in list instead of his id ?

J
Jane 5/30/2011

Hi,
you can set up this field as disabled in the JavaScript onload event on the Eventstab:

http://xlinesoft.com/asprunnerpro/docs/ctrl_setdisabled.htm

U
unsearcheable author 5/31/2011



Hi,
you can set up this field as disabled in the JavaScript onload event on the Eventstab:

http://xlinesoft.com/asprunnerpro/docs/ctrl_setdisabled.htm


Hello Jane.

When adding record it works, but it records 0 instead of 1 that is the session userid. Also when Listing appears userid instead of its name.

J
Jane 6/1/2011

Hi,
to save actual value use Before record added event on the Eventstab:

$values["Editor"] = $_SESSION["UserID"];


Regarding the second issue.

It's difficult to tell you what's happening without seeing actual files.

Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.