Jump to content


Photo

Help with updating database record


  • Please log in to reply
2 replies to this topic

#1 DirtDemon

DirtDemon
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 19 May 2006 - 08:39 PM

Hello, hopefully someone can find the one little thing that most likly is causing my problem.

Here is the breakdown.

1 MySQL Table with email as username, password, and a bunch of other profile fields.
1 working registration page and login page.

The registration page inserts the new email and password into the DB after checking for unique email.

The login page succesfully logs you in because I am calling the session username and it displays the correct email that I logged in with, I have created three test records.

So here is the issue. When you successfully login I take you to a profile update page. This will show your email and password along with all those other fields so that you can fill them out or change them and then Update the record. Well that works sort of, I can make changes to the data it shows and click update and it all gets updated but......

The problem is that no matter who I log in as it ALWAYS shows the first record. It isnt taking the email (username field) and matching it up to the correct record to show the data.

So how can I correct this? I can post code upon request or you can take a look here at the actual site and test it. [a href=\"http://www.redesign.maximumdirt.com/profiles.php\" target=\"_blank\"]http://www.redesign.maximumdirt.com/profiles.php[/a]

Any help would be greatly appreciated!!!


#2 jeremywesselman

jeremywesselman
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts
  • LocationIndependence, KY

Posted 21 May 2006 - 06:13 AM

When you pull the record from the database, you need to specify which record to pull. Since you are using their email in a session var, you could also use it to pull the correct record from the database to show.

<?php
$sql = "SELECT * FROM table WHERE email = '" . $_SESSION['email'] . "'";
?>

Your query to get the correct record would look something like that. Then, when you want to update the record, use something like this:

<?php
$sql = "UPDATE table SET blah = '$blah' WHERE email = '" . $_SESSION['email'] . "'";
?>

Your update query would look something like that, but more complex.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

#3 DirtDemon

DirtDemon
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 25 May 2006 - 12:50 AM

THANKS!

[img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

Got it figured out!

Andy




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users