DMXzone Security Provider PHP Support Product Page

Answered

When creating an insert form how do you add a logged in users id to a hidden field?

Asked 08 Jun 2017 17:37:19
1
has this question
08 Jun 2017 17:37:19 Matthew Da Cruz posted:
I need to add the logged in user id to a hidden field when they do an insert into the database.
How is this done?

Regards

Matt

Replies

Replied 09 Jun 2017 06:46:49
09 Jun 2017 06:46:49 Teodor Kuduschiev replied:
Hello Matt,
You do not need to add the validation to the hidden field. You can add it directly in the insert step.
The session is generated like: SecurityProviderName+"Id"
So if your security provider name in the server connect is called: dbUsers then your session name is: dbUsersId
So you can define this session under Globals > Sessions in your server action and use it as a value in the insert step.
Replied 12 Jun 2017 07:37:27
12 Jun 2017 07:37:27 Matthew Da Cruz replied:
HI Teodor

I have followed your instructions.
My Security Provider =dbUser
My User id field in DB = user_id
My server action : Projects/Insert
In my steps I have
Dtabase connection: localhost
Database insert: Insert_Project
Security Provider:dbUser

In the Database Update Action Builder
I am inserting into the Projects table in DB successfully except the session logded in user.

In the page code I have the following for the Server Connect Action Executors: Insert_Project

The session id is not created.
Am I missing something in the steps or Globals?

In the dmxconnect/api/projects/insert

the session is set as


"$_SESSION":

"type": "number",
"fieldName": "user_id",
"name": "dbUseruser_id"


Any idea what I have done wrong?

Regards

Matt
Replied 12 Jun 2017 07:38:07
12 Jun 2017 07:38:07 Matthew Da Cruz replied:
"id": "Insert_Project", "url": "dmxConnect/api/Projects/Insert.php", "form": "#new_project", "data": {"user_id": "{{$_SESSION.dbUseruser_id}}"}, "onSuccess": "MM_goToURL('parent','index.php')
Replied 12 Jun 2017 07:46:05
12 Jun 2017 07:46:05 Teodor Kuduschiev replied:
If your security provider name is dbUser then the session, which stores the user id is called: dbUserId and not dbUseruser_id that you used ...
Replied 12 Jun 2017 13:41:59
12 Jun 2017 13:41:59 Matthew Da Cruz replied:
Hi Got it figured out - Thanks

Reply to this topic