DirtDemon Posted May 19, 2006 Share Posted May 19, 2006 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!!! Quote Link to comment https://forums.phpfreaks.com/topic/10036-help-with-updating-database-record/ Share on other sites More sharing options...
jeremywesselman Posted May 21, 2006 Share Posted May 21, 2006 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--] Quote Link to comment https://forums.phpfreaks.com/topic/10036-help-with-updating-database-record/#findComment-37593 Share on other sites More sharing options...
DirtDemon Posted May 25, 2006 Author Share Posted May 25, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/10036-help-with-updating-database-record/#findComment-38746 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.