Populating a form from a DB?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cheddar
Forum Newbie
Posts: 7
Joined: Tue Nov 25, 2003 4:23 pm
Location: UK

Populating a form from a DB?

Post by cheddar »

Can anyone help me out again, I have some information stored in a DB and I want the user to be able to update it.

At the moment I have a login page that the user goes to and logins in, a session variable is then created and the user redirected to a 'amend' page. I check on this page for the presence of the session variable, if it doesnt exist then I kick them back to the login page. The session variable contains the users email address that I want to use to grab their information and display it in a form for them to update.

I have got the form done in dreamweaver, it's the same as the form I use to create a new user. I have all the code to create a new users so I can adapt that to update the users record but I have no idea at all how to populate the form.

I have searched all over for a tutorial but I just cant seem to find anything. Can anyone help me out here, i'm totally lost.

Thanks.
User avatar
gjb79
Forum Commoner
Posts: 96
Joined: Fri Jul 18, 2003 6:35 am
Location: x <-- (DC)
Contact:

Post by gjb79 »

Well you'll need to first call up the database and, using the email address, extract from the table.
something like select columns_you_need from table_name where email_column == email_address

Then use the variables this pulls up to populate your form. input type="textarea" value="$value_from_select_query"

when you save you just update from table_name where column_in_table = $item_from_form

theres a basic run down. might need adjusting
Post Reply