Assign certain value to a user

Hi everyone, I tried to assign a value to a user, but I can’t make this work, I’ll explain to you what I can’t do.

I am trying to make this Auto-Replacement system into my app:

Every user login, and can find TWO fields: one is called IP and another is called PASSWORD.

Warning: those aren’t their credentials! IP and Password will be replaced with an IP and a Password picked from the DB.

So I am a user, I log in. I want a new IP and Password to be assigned to my fields, so I click on “Get Replacement” button.

Now it has to do some stuff:

  • Go into App Data and get IP & Pass from their corresponding fields, in a DB called “machine.”
  • Set the status of that IP & Pass to “used=yes”
  • Assign it to the user, and the user is the only one who uses that “machine” (Until I set it to “used=no” so that the next user will pick it).

I hope I was clear. Isn’t easy to explain, and for me, it isn’t easy to make too.
Thank you for your help.

Anyone who can help with this?
I am still stuck in this part.

Can you explain what it is you’re trying to do and MORE IMPORTANTLY, why? I’m talking about the rationale here, not what you’ve tried.

@keith Sure.
As I said, I need to assign these combos of IP&Pass to my users, whenever they request it by clicking a button.

Why? Because they pay for this. I need this system to assign these combos.
So every time user clicks on that button, it has to:

  • verify via API if the combo is still valid (if yes, it won’t be replaced)
  • if the response is no, get a combo from the DB (where otherwise?) and replace it by assigning a new one (and deleting the old).

I don’t think there is a better or most straightforward solution.
What do you think?

I would ditch the “Used Y/N” and replace it by something like “In Use By User” which is set to have a type of User.

Then when someone requests the “machine” you update this field with the Current User.

When it is freed up, you set it to null.

Sure, that’s a good solution, but it isn’t complete.
Because I need to put somewhere in the DB these combos IP:PASS, so that the system can automatically take it and assign to the user.

And also I need to verify if combo is still valid via an API, because if it is, it cannot be replaced.

Still looking for a solution.