Reputation: 754
I am building the profile section of a php site. It offers a profile edit section. Say, I have the details user_id, user_name, user_firstname, user_lastname,user_email in my $_SESSION variable.
So, if any user edits any of these attributes, by going to localhost/profile/edit, how should I go on about updating the database columns that have been changed?
ie 1. Should I compare the post data with my session variable and update only the changed fields? But I don't know how to implement this.
Should I update all fields?
SOme other standard way of doing things?
If you need more clarification, let me know.
Upvotes: 0
Views: 92
Reputation: 479
Between update all fields and just on field it's up to you. In a REST perspective you should use a PUT to update the whole resource and a PATCH to update just one field of the resource. So i think is really up to you!
In any case the flow should be:
Upvotes: 3