Forum Moderators: coopster

Message Too Old, No Replies

Need help please re: PHP/MySQL Member Profile Self-Service Update

Tied into a simple MySQL database

         

Waypointer

1:10 pm on Oct 13, 2005 (gmt 0)

10+ Year Member



I know it's here but I can't find previous posts after searching... I have a simple MySQL table including name, address, occupation, email, etc (13 fields), and I am trying to create a simple PHP script to allow 1.) review of current member "profile" (that record echo'd back by user name) and 2.) ability to update that profile (i.e., record by username), and 3.) only be able to add to/revise/delete their own information, not other users' data.

I am grateful for any help!

Many thanks.

jatar_k

3:49 pm on Oct 13, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't know what level of direction you need here so don't be offended if I present something that is too simple

there are some threads in the PHP Library [webmasterworld.com] about MySQL
Basics of extracting data from MySQL using PHP [webmasterworld.com]
Common MySQL Commands [webmasterworld.com]

well the first thing to do is to SELECT the information for that member and load it into a form. Your table hopefully has some unique identifier for each member which is what you will need in your select query.

You then need to allow them to edit the fields you decide should be editable.

They can then submit that form

You need to validate all user entered data

then issue an UPDATE query using that same unique identifier

Waypointer

7:36 pm on Oct 13, 2005 (gmt 0)

10+ Year Member



Simplicity is good! Thanks.

Have you ever seen sample code that I could learn from for a self-service member profile PHP script?

Thanks again.

Waypointer

7:38 pm on Oct 13, 2005 (gmt 0)

10+ Year Member



"Unique Identifier" would be the username, correct?

I am also planning on creating a self-registration interface where the visitor creates his own username (checks to see if it is unique) and password...

Thanks again.

jatar_k

8:13 pm on Oct 13, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I like having a unique id as well even if the username is unique

then if the username ever changes I still retain the id and can track full history even across username changes. Plus queries on a numeric field will be better than a text field.

>> code samples

the thread above "Basics of extracting data from MySQL using PHP" shows how to get the data out of mysql

then you need to display it in a form

just make an html form that has fields for each piece of information you want them to be able to edit. Keep in mind hidden fields for getting data into the form that you don't want them to edit but that you may need when you need to update their information.

when the user submits the changes you need to check every field to make sure it is of the right type, right length etc.

then once you are sure everything is on the up and up you can then issue an UPDATE query to mysql.

take a look at that library link above, there are threads in there about data validation (security) and there is a thread about Peer code review which has some interesting parts.

start with the form
then work on loading the data into it
then worry about updating it

Waypointer

8:18 pm on Oct 13, 2005 (gmt 0)

10+ Year Member



Thanks again for your time - I have a lot of time ahead of me to program, test, repeat.

Cheers!

jatar_k

8:19 pm on Oct 13, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



take it piece by piece and you will figure it out

if you try to do all the parts at once you'll pull all your hair out before it gets done ;)