Page 1 of 1

Populating a form from a DB?

Posted: Sun Nov 30, 2003 2:34 pm
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.

Posted: Sun Nov 30, 2003 2:47 pm
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