Page 1 of 1
Update Information...
Posted: Wed Aug 06, 2008 10:54 am
by lostprophetpunk
I am working on a member system at the moment.
I have for my database table the following fields...
id
email
password
The thing that I am trying to do is to create a form with a script to let the user update the information. I would like the form to post to self.
How would I go about doing this?
Thanks in advance.
Re: Update Information...
Posted: Wed Aug 06, 2008 10:56 am
by Dynamis
lostprophetpunk wrote:The thing that I am trying to do is to create a form with a script to let the user update the information. I would like the form to post to self.
assume this is example.php:
Code: Select all
<?php
//code to handle the form here
?>
<form action="example.php" method="post">
<!-- Form information here -->
</form>
Re: Update Information...
Posted: Wed Aug 06, 2008 11:13 am
by lostprophetpunk
I know how to do the form.
It is just the code for updating the user information that I do not know. As you have to be able to update the table with new information, thus making it so that the user can edit their information.
Re: Update Information...
Posted: Wed Aug 06, 2008 11:30 am
by Dynamis
lostprophetpunk wrote:It is just the code for updating the user information that I do not know. As you have to be able to update the table with new information, thus making it so that the user can edit their information.
So here is how I handle this (example.php):
Code: Select all
<?php
//insert form handle code here
$q = "Select * from "..... //put the code there to get the user info
$result = mysql_query($q);
$user_info = mysql_fetch_array($result);
?>
<form action="example.php" method="post">
<input type="text" name="name" value="<?php echo $user_info['name'] ?>">
</form>
As you can see in the form, you simply fill in the value with the correct info from the database for that user. If they have no info it is blank, etc. Also, since you handle the form each time before the form is displayed, the new information will be displayed in the form each time the page is reloaded. Hope that answers your question.