Jump to content

need to provide UPDATE to member profiles - not working


simcoweb

Recommended Posts

I have member profiles that I would like them to be able to update from a member control panel link that uses their memberid to summon their data into a prepopulated form. I'm using this method to populate the form fields with their current data. Not sure if this is the right way to do it but it's the way I have working now:

MySQL:
[quote]$sql = "SELECT * FROM plateau_pros WHERE memberid='$memberid'";
$result = mysql_query($sql, $conn) or die(mysql_error());[/quote]

page and form displayed as:

[code]<?php
while ($a_row = mysql_fetch_array($result)) {
  echo "
  <form action='updatemember.php' method='POST'>
  <table width='95%' border='0' align='center'>
  <tr>
  <td><font class='bodytext'>First name: </td><td><input type='text' size='30' value='" . $a_row['firstname'] . "'></td>
  </tr>
  <tr>
  <td><font class='bodytext'>Last name: </td><td><input type='text' size='30' value='" . $a_row['lastname'] . "'></td>
  </tr>
  <tr>
  <td><font class='bodytext'>Business name: </td><td><input type='text' size='30' value='" . $a_row['business'] . "'></td>
  </tr>
  <tr>
  <td><font class='bodytext'>Your title: </td><td><input type='text' size='30' value='" . $a_row['title'] . "'></td>
  </tr>
  <tr>
  <td><font class='bodytext'>Address: </td><td><input type='text' size='30' value='" . $a_row['address'] . "'></td>
  </tr>
  <tr>
  <td><font class='bodytext'>City: </td><td><input type='text' size='30' value='" . $a_row['city'] . "'></td>
  </tr>
  <tr>
  <td><font class='bodytext'>Zip code: </td><td><input type='text' size='30' value='" . $a_row['zip'] . "'></td>
  </tr>
  <tr>
  <td><font class='bodytext'>Phone: </td><td><input type='text' size='30' value='" . $a_row['phone'] . "'></td>
  </tr>
  <tr>
  <td><font class='bodytext'>Fax: </td><td><input type='text' size='30' value='" . $a_row['fax'] . "'></td>
  </tr>
  <tr>
  <td><font class='bodytext'>Email: </td><td><input type='text' size='30' value='" . $a_row['email'] . "'></td>
  </tr>
  <tr>
  <td><font class='bodytext'>Details: </td><td><textarea cols='30' rows='5' value=''>" . $a_row['comments'] . "</textarea></td>
  </tr>
  <tr>
  <td><font class='bodytext'>Specialties: </td><td><textarea cols='30' rows='5' value=''>" . $a_row['specialties'] . "</textarea></td>
  </tr>
  <tr>
  <td><input type='submit' value='Update' name='update'></td>
  </tr>
  </table>
  </form>
  <p>\n";
?>[/code]

The form gets populated with the current data. They can edit their changes then hit 'Update' button which would then write this query:

[code]<?php
$sql = "UPDATE plateau_pros SET firstname='$firstname', lastname='$lastname', business='$business', title='$title', address='$address', city='$city', zip='$zip', phone='$phone', fax='$fax', mobile='$mobile', email='$email', comments='$comments', specialties='$specialties' WHERE memberid='$memberid'";
$result = mysql_query($sql, $conn) or die(mysql_error());
?>[/code]

Which, when I [code]<?php echo $result ?>[/code] I get the number '1' which indicates one row has been updated. However, when I check the fields in the MySQL database nothing has been changed or added.
Link to comment
Share on other sites

:)
One small thing is missing-'name' attrribut for textfields:
First name: <td><input type='text' size='30' value='" . $a_row['firstname'] . "'></td>
should be:
<td><input type='text' [color=blue][font=Verdana]name='firstname' [/font][/color]size='30' value='" . $a_row['firstname'] . "'></td>

Also, pay attention to retrieve $_POST($vars) properly.

Link to comment
Share on other sites

DOHHHHHHHHh! Ok, overlooked that in my haste. That's why it's always good to have another set of eyes looking at this stuff. Sometimes the obvious becomes the oblivious.

I'll insert the name tags.

For this:
[quote]Also, pay attention to retrieve $_POST($vars) properly.[/quote]

Can you elaboarate on what you mean by that? Thanks for the post!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.