Jump to content

Just started PHP and need some help.


Amj190

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.