This topic is locked
[SOLVED]

 Add username via editor

3/4/2020 11:35:19 AM
PHPRunner General questions
P
PaulM author

I have a field in a table signed_by. I want this field to default to the current logged in user when the row is added and changed if a different user is logged in when the row is edited. I've tried :user.fullname and $_session[user_id] in the editor as a default value and the AutoUpdate value but it doesn't work.
Any help would be gratefully received.
Thanks

mbintex 3/5/2020
Sergey Kornilov admin 3/7/2020

Use the following as default value:

Security::getUserName()


More info:

https://xlinesoft.com/phprunner/docs/secapi_get_user_name.htm

P
PaulM author 4/27/2020



Use the following as default value:

Security::getUserName()


More info:

https://xlinesoft.com/phprunner/docs/secapi_get_user_name.htm


I've tried this but it still doesn't work and only $LD_id is put into the Dummy_Table.
$result["agree"] = $params["agree"];

$userName = Security::getUserName();
IF($params["agree"] == "Yes")

{

$record = $button->getCurrentRecord();

$LD_id = $record["LD_id"];

$sql = "update Landlord_Documents set LD_number_of_signatures_required = LD_number_of_signatures_required-1 where LD_id=$LD_id";

DB::Exec($sql);

$sql = "insert into Dummy_Table(DT_details) values (".$LD_id.")";

DB::Exec($sql);

$sql = "insert into Dummy_Table(DT_details) values (".$userName.")";

DB::Exec($sql);

D
DealerModulesDevClub member 4/27/2020



I have a field in a table signed_by. I want this field to default to the current logged in user when the row is added and changed if a different user is logged in when the row is edited. I've tried :user.fullname and $_session[user_id] in the editor as a default value and the AutoUpdate value but it doesn't work.
Any help would be gratefully received.
Thanks


In my apps I am using $_SESSION["UserName"] instead of $_session[user_id] that you mentioned above.
In the "add" page I am on using as default value.

In the "edit" page I am using this for the default and AutoUpdate value.
Paul

P
PaulM author 4/27/2020



In my apps I am using $_SESSION["UserName"] instead of $_session[user_id] that you mentioned above.
In the "add" page I am on using as default value.

In the "edit" page I am using this for the default and AutoUpdate value.
Paul


Thanks, I'll give that a try.

Sergey Kornilov admin 4/27/2020

@PaulM,
you doing yourself a huge disservice trying to craft SQL Queries manually and forgetting to add single quotes around $userName.
You need to use Database API that takes care of things like this:

https://xlinesoft.com/phprunner/docs/db_insert.htm

P
PaulM author 4/28/2020



@PaulM,
you doing yourself a huge disservice trying to craft SQL Queries manually and forgetting to add single quotes around $userName.
You need to use Database API that takes care of things like this:

https://xlinesoft.com/phprunner/docs/db_insert.htm


Thanks, schoolboy error but all fixed now. I won't forget the quotes again.