Jump to content

Archived

This topic is now archived and is closed to further replies.

DirtDemon

Help with updating database record

Recommended Posts

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!!!

Share this post


Link to post
Share on other sites
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.

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

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

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

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

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

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.