Update profile

Reply

Join Date: Dec 2008
Posts: 2
Reputation: oluchan is an unknown quantity at this point 
Solved Threads: 0
oluchan oluchan is offline Offline
Newbie Poster

Update profile

 
0
  #1
Jan 13th, 2009
Pla can anyone help me with user profile update script.
when user log in with their email and password, the page will redirect user to my account section where user can update profile. how do i populate user details on update profile link.
I will appreciate any help.
Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 93
Reputation: humbug is an unknown quantity at this point 
Solved Threads: 13
humbug's Avatar
humbug humbug is offline Offline
Junior Poster in Training

Re: Update profile

 
0
  #2
Jan 13th, 2009
Assuming you have all the data stored in a MySQL table you sould need something like this:
  1. <?php
  2. //login to MySQL db
  3.  
  4. $result=mysql_query("SELECT * FROM user_settings WHERE id='$_SESSION[user_id]'");
  5. $settings=mysql_fetch_array($result); //now $settings has everything from the user_settings table as an array
  6. echo '<form action=...>'.
  7. ' <input type="text" name="real_name" value="'.$settings['real_name'].'">'.
  8. ' ...'.
  9. '</form>';
  10. ?>
This code should output the following where "MY NAME" is the value in the "real_name" column of table "user_settings" in the row with id equal to $_SESSION[user_id].
  1. <form action=...>
  2. <input type="text" name="real_name" value="MY NAME">
  3. ...
  4. </form>
You can use the values in the $settings array to fill all of the inputs with the current data. (The code is untested BTW, so may contain syntax errors...)

Hope that helped.
"If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 2
Reputation: oluchan is an unknown quantity at this point 
Solved Threads: 0
oluchan oluchan is offline Offline
Newbie Poster

Re: Update profile

 
0
  #3
Jan 16th, 2009
Thanks mate, i finnaly got it working. I appreciate your effort.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 1
Reputation: remp is an unknown quantity at this point 
Solved Threads: 0
remp remp is offline Offline
Newbie Poster

Re: Update profile

 
0
  #4
May 5th, 2009
Hello, would it be too much to ask you to help me accomplish the same thing oluchan accomplished?
i don't have anything yet and i have gone crazy looking for something like this... i would REALLY appreciate it, if you could share the script. THANK YOU very much in advance.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 93
Reputation: humbug is an unknown quantity at this point 
Solved Threads: 13
humbug's Avatar
humbug humbug is offline Offline
Junior Poster in Training

Re: Update profile

 
0
  #5
May 5th, 2009
I am not going to write your code for you - that's the sort of thing I get paid for - but I will help you do it yourself.

The way I would do it is as follows:
You will need
  • A place to store the data (MySQL table)
  • A form for the user to edit the data (form.php)
  • A script that will process any data that the user submits (save.php)

When you create the user, you can create an empty entry in the MySQL table.

form.php will first get the stored data and echo the html for a form using the trick above to put the data into the "value" attribute of the inputs in your form. This way, all the fields are already filled in with whatever the user entered last time.

The form should be pointed at the script that deals with the data (action="save.php"). save.php will use the data to create an UPDATE query for the database.

If you don't know how to do any of these steps, look at tutorials for each step (starting with forms, etc.) and you will soon learn how it all works, that's what I did!
"If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: Update profile

 
0
  #6
May 5th, 2009
apply update quesry after testing if record already exist on the basis of session variable
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 93
Reputation: humbug is an unknown quantity at this point 
Solved Threads: 13
humbug's Avatar
humbug humbug is offline Offline
Junior Poster in Training

Re: Update profile

 
0
  #7
May 5th, 2009
You could even use an "INSERT ... ON DUPLICATE KEY UPDATE ..." query (if you have a primary key "id" column) but that's getting complicated.
"If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC