Amj190 Posted May 21, 2015 Share Posted May 21, 2015 Hello, I am a student studying PHP and have been asked to create a website that has the ability to a user to update their username, password and email. At the moment, a user can sign up, and they give their username, password and email, which is then stored on a server. I don't dislike PHP at all, but my teacher did not teach us anything - he gave us links to pages, and we have all had to learn it ourselves as a result (not terrible but at least giving some help would have been appreciated). I am unsure how to do this, as he gave us no links or help on how to do this, I have tried looking up solutions online but its a little overwhelming some of the stuff I have found - if somebody can explain to me how I can allow a user to update these things, I would very much appreciate it. Thank you. Quote Link to comment Share on other sites More sharing options...
Barand Posted May 21, 2015 Share Posted May 21, 2015 Using the user's id you would select the user's record and display the current values in text boxes in a form (which would look similar to your input form). The user edits the data (don't allow changes to the id) then instead of INSERT you would use an UPDATE query to update the user's record. Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 21, 2015 Share Posted May 21, 2015 I typically use one form for both the create and update scenarios. I will include a hidden field for the ID field. For a scenario where the user requests to create a new record the hidden field will be empty or 0. But, if the user selects to update a record, I will query the data for that user and populate the fields (including the hidden field) as Brand stated above. Then, when the form is posted, I would simply do a check to see if the id field is set or not. If yes, perform an UPDATE query - else I perform an INSERT query. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.