943,840 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2460
  • PHP RSS
Jan 13th, 2009
0

Update profile

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
oluchan is offline Offline
2 posts
since Dec 2008
Jan 13th, 2009
0

Re: Update profile

Assuming you have all the data stored in a MySQL table you sould need something like this:
php Syntax (Toggle Plain Text)
  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].
PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 20
Solved Threads: 13
Junior Poster in Training
humbug is offline Offline
93 posts
since Oct 2005
Jan 16th, 2009
0

Re: Update profile

Thanks mate, i finnaly got it working. I appreciate your effort.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
oluchan is offline Offline
2 posts
since Dec 2008
May 5th, 2009
0

Re: Update profile

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
remp is offline Offline
1 posts
since May 2009
May 5th, 2009
0

Re: Update profile

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!
Reputation Points: 20
Solved Threads: 13
Junior Poster in Training
humbug is offline Offline
93 posts
since Oct 2005
May 5th, 2009
0

Re: Update profile

apply update quesry after testing if record already exist on the basis of session variable
Reputation Points: 16
Solved Threads: 48
Posting Whiz
BzzBee is offline Offline
327 posts
since Apr 2009
May 5th, 2009
0

Re: Update profile

You could even use an "INSERT ... ON DUPLICATE KEY UPDATE ..." query (if you have a primary key "id" column) but that's getting complicated.
Reputation Points: 20
Solved Threads: 13
Junior Poster in Training
humbug is offline Offline
93 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: use listbox to insert data?
Next Thread in PHP Forum Timeline: need help in country state drop down





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC