Update Information...

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
lostprophetpunk
Forum Newbie
Posts: 21
Joined: Sat May 31, 2008 3:49 am

Update Information...

Post 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.
Dynamis
Forum Contributor
Posts: 122
Joined: Thu Jul 10, 2008 3:15 pm
Location: Indiana, US

Re: Update Information...

Post 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>
 
lostprophetpunk
Forum Newbie
Posts: 21
Joined: Sat May 31, 2008 3:49 am

Re: Update Information...

Post 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.
Dynamis
Forum Contributor
Posts: 122
Joined: Thu Jul 10, 2008 3:15 pm
Location: Indiana, US

Re: Update Information...

Post 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.
Post Reply