| | |
Update profile
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Assuming you have all the data stored in a MySQL table you sould need something like this:
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].
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.
php Syntax (Toggle Plain Text)
<?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>'; ?>
PHP Syntax (Toggle Plain Text)
<form action=...> <input type="text" name="real_name" value="MY NAME"> ... </form>
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.
★ 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.
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
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!
- 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.
★ 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.
•
•
Join Date: Apr 2009
Posts: 257
Reputation:
Solved Threads: 37
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.
★ "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.
★ 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.
![]() |
Similar Threads
- update profile (DaniWeb Community Feedback)
- Help with a Profile Managment System (Perl)
- 2 fields won't update in mysql db (PHP)
- Updating Profile (PHP)
- how to update profile of login member (C#)
- ASP.Net VB Page to update a users profile not updating. (MS SQL)
- Are we seeing a PR update? (Search Engine Optimization)
Other Threads in the PHP Forum
- Previous Thread: convert .doc to html or txt on fly (during upload) with PHP
- Next Thread: Php search string
| Thread Tools | Search this Thread |
advanced ajax apache api array basics beginner binary broken cakephp check checkbox class cms code combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert integration ip java javascript job joomla js limit link login loop mail menu mlm multiple mysql oop parse password paypal pdf php problem procedure query radio random recursion regex remote script search server sessions smarty smash sms soap source space sql stored syntax system table traffic tutorial unicode update upload url validator variable video web xml youtube





