Insert userid into other tables when making new user

I have a table called “allusers” which stores userid, username, password and level. I have an insert form to make new user. Now I would like, upon inserting a new user, two other tables to make a new record and store the userid in them as well.
Can this be done? If so, than how do I go about doing that?

Hello @web-works
Just add two more insert record steps in your server action, after the insert user step you already have.
You can access the inserted record ID like explained here:

That’s a real cool feature. Thanks

Stange thing happens. With existing users this will work perfectly. But after adding new users, it will not load the necessary information.
Existing user: frans/eva2110
New user: admin/admin1234
I don’t understand why this is happening

What exactly does not happen? Can you explain more detailed what’s wrong exactly?

The idea is that users sign up
This form works as should and fills two database tables: allusers (with login data and id_user) and nawg (with companyname and id_user). It does that as expected.
After signing up the new user will receive a mail with his login data and a link to login and edit their own info in “nawg”.
Old users that were in table allusers and nawg can login en edit their data based on id_user. New users can’t. Which I think is very strange as in both cases same data are used.

I am not sure i understand what are you doing exactly?
You asked how to use the inserted record id in another two insert record steps. Isn’t that working?

Yes, that is working. It will insert the users etc.
Point is that there appears to be a difference between users that were in the database table already and new users when logging in.
The old users get their info after logging in, but new users don’t although the data is the same.
Which is very odd.
So users sign up with
After signing up they can login at
Although the new user data was inserted correctly to the database, and they can login, the related data is not shown (login: admin/admin1234). Users that were in the database before making these pages can login and their data is shown (login: frans/eva2110)
This is weird!

Sorry but you totally lost me :slight_smile:

Are you sure the related data is properly “related” and filtered by the same ID?
If the data is properly inserted there should be no issues.

I assume that if I call an existing user and the proper related data shows it means the filter is ok. That’s why I think it is weird that only previously existing users will show and new users don’t.
User table:

Nawg table:
Filter is id_user

Your /dmxConnect/api/content/nawg.php server action returns “unauthorized”, when you log in - which means something is not properly configured in the security provider you are using to protect it.

Even stranger, as I don’t get the “unauthorized” message when logging in.
Logging in frans gives:

which is correct.
Logging in admin gives: which is wrong

Found it. It appears that it will not only check for username+password+level, but also for emailaddress. So it will check for all the fields in the table “users”

@web-works i am referring to the reply in the dev tools

Hi @Teodor,
Can I just ask what happens with multiple insert action steps if a step fails? Will the transaction roll back or will the previous steps have committed?


What do you mean by if it fails? What kind of a fail are you referring to?

Hi @Teodor,
Thank for coming back to me so quickly. I’m thinking if the DB insert query fails (not because of Wappler) but because maybe a data type was wrong or a required field had been missed - or more likely a duplicate/unique key collision. What would happen? I have used transactions in PHP before and rolled back upon failure.

The server action will just stop and return an error status, it won’t do any data restore etc.

If you want to do anything in case of such a server error (500) you can use he catch step. Learn more about the catch step here:


Thanks @Teodor,
That makes sense.

1 Like