Dada78 Posted August 22, 2008 Share Posted August 22, 2008 Hello, I have a site that has a simple login script to a control panel where users can mange and edit Christmas displays they submit. Well while validating some HTML code this week I removed the php code from the userindex that controls the session and SQL call and put it on a notepad so I could navigated around without having to be logged in. Well I had to restart my computer and I was closing these notepads out and thought I was done with this one and didn't save it. Come to find out if had the small code for the php that controlled the user index so members will be logged into their control panel. I pulled a back up from my host but it didn't have the new code. I can not remember all of the code but it made a SQL Query which I have but their is one bit of code that was before it that I can not remember that was a session code that checked if the user was logged in with the correct email then it query the DB and showed the users information. Can anyone help me out with this small task and remind me what I am forgetting. This is the code I am working with and it is missing just one small line and I can not remember... The user can see their information but I had it when they logged in it were display their Christmas Display name at the top and it would say Hi Welcome back so and so... I can not pull that information anymore. <?php require ('session.php'); include ('db_connect.php'); $sql = "SELECT * FROM users WHERE email = $email;"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $row = mysql_fetch_array($result); $id = $row["id"]; $displayname = $row["displayname"]; $name = $row["name"]; } else { die(mysql_error()); } } ?> -Thanks Link to comment https://forums.phpfreaks.com/topic/120867-solved-lost-important-code-now-can-not-login-to-control-panel/ Share on other sites More sharing options...
Mchl Posted August 22, 2008 Share Posted August 22, 2008 try print_r($_SESSION) to display variables stored in session. Then maybe you;ll be able to figure out something more For the future: Separate php and html as much as possible (and much is possible) Use SVN or some other version control tool, so that you can always rollback your changes. Link to comment https://forums.phpfreaks.com/topic/120867-solved-lost-important-code-now-can-not-login-to-control-panel/#findComment-623038 Share on other sites More sharing options...
Dada78 Posted August 22, 2008 Author Share Posted August 22, 2008 It pretty much is separate for the most part. That is the only php code in that HTML file and it is just a small bit, and if you noticed two of the files are included. I just need a small SQL to query the display name and users name. I had it set up and working perfect but removed the code and deleted it on accident and cant remember how I had it. It is something a long these lines, but I need it to just pull the information in the query for that user that is logged in and it is not doing that. It has some kind of session email string but cant remember it. <?php require ('session.php'); include ('db_connect.php'); $sql = "SELECT * FROM users WHERE email='$email'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $row = mysql_fetch_array($result); $id = $row["id"]; $displayname = $row['displayname']; $name = $row['name']; } } ?> Link to comment https://forums.phpfreaks.com/topic/120867-solved-lost-important-code-now-can-not-login-to-control-panel/#findComment-623052 Share on other sites More sharing options...
Mchl Posted August 22, 2008 Share Posted August 22, 2008 Did you try to printout what's stored in session? Link to comment https://forums.phpfreaks.com/topic/120867-solved-lost-important-code-now-can-not-login-to-control-panel/#findComment-623082 Share on other sites More sharing options...
Dada78 Posted August 22, 2008 Author Share Posted August 22, 2008 No that is not what I was looking for... I got it all sorted now. I was looking for this to add to the Query.. $email = $_SESSION['email']; Link to comment https://forums.phpfreaks.com/topic/120867-solved-lost-important-code-now-can-not-login-to-control-panel/#findComment-623096 Share on other sites More sharing options...
Mchl Posted August 22, 2008 Share Posted August 22, 2008 Good for you. Now do a backup Link to comment https://forums.phpfreaks.com/topic/120867-solved-lost-important-code-now-can-not-login-to-control-panel/#findComment-623180 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.