Jump to content

[SOLVED] Lost important code now can not login to control panel


Dada78

Recommended Posts

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

 

 

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.

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'];
  }
}

?>

Archived

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

×
×
  • 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.