In my DB i have a table that stores my site settings per user. The columns look like this:
id, user, componentType, text, value, active (0 or 1)
And some demo data would be:
1, 1, 1, "Gallery", "/gallery", 1
2, 1, 1, "Poll", "/poll", 0
NOW, i have made a page that lists all settings for the user, the above are for me. This page lets you change text and active(checkbox).
Displaying them on the webpage is a no-brainer, but how do i do it when i post it back to the server? Some users have more settings then others… i was thinking of doing something like this per setting, the data below is for the first setting for my user:
<input type="text" name="text-1", value="Gallery" />
<input type="checkbox" name="active-1" checked />
I’m not 100% steady when it comes to php regex and stuff, but im guessing that is the way i have to go when i dont know what settings that are comming in to the server from the form?
As I understand you always edit the settings for one particular user. Then you can add a hidden form field into your form which tells you which user is the one editing the settings.
The other option would be, as you wrote, to add the userID information directly to the name of the field and then parse it. But I would recommend the first option with hidden field.