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

Assuming you have all the data stored in a MySQL table you sould need something like this:

<?php
//login to  MySQL db

$result=mysql_query("SELECT * FROM user_settings WHERE id='$_SESSION[user_id]'");
$settings=mysql_fetch_array($result); //now $settings has everything from the user_settings table as an array
echo '<form action=...>'.
     '  <input type="text" name="real_name" value="'.$settings['real_name'].'">'.
     '  ...'.
     '</form>';
?>

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].

<form action=...>
  <input type="text" name="real_name" value="MY NAME">
  ...
</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.

Thanks mate, i finnaly got it working. I appreciate your effort.

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.

I am not going to write your code for you - that's the sort of thing I get paid for :P - 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!

apply update quesry after testing if record already exist on the basis of session variable

You could even use an "INSERT ... ON DUPLICATE KEY UPDATE ..." query (if you have a primary key "id" column) but that's getting complicated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.