Jump to content

[SOLVED] Login Session Dont Wanna Work


Zepo.

Recommended Posts

Ok i got it to when there is a session, it will auto login for them, it works the first time you leave the page and come back but anything after that it doesnt.

 

Demo: http://eliteladders.com/devlopment/admincp/

Login : Hogen

pass : demo

 

File:

<?
include("../config.php");
session_start();

$admin=check_login($admin);

switch($action){
default:
admin_main($admin);
break;
}


function check_login($admin){
global $config;

if($admin[fail]){
$userip=getenv("REMOTE_ADDR");
$failed=" <font color='#FF0000' size='1'>(Incorrect Login $userip)</font>";

$adminlog[admin]="$admin[name]";
$adminlog[adminid]="$admin[id]";
$adminlog[details]="Failed Admin Login: Name: $admin[name] IP: $userip";
adminlog($adminlog);

}

if(isset($_SESSION['name'])){
$admin=mysql_query("SELECT * FROM staff WHERE name='{$_SESSION['name']}' AND password='{$_SESSION['pass']}' AND rights > '0'");
$admin=mysql_fetch_array($admin);
}else{
$admin=mysql_query("SELECT * FROM staff WHERE name='$admin[name]' AND password='$admin[pass]' AND rights > '0'");
$admin=mysql_fetch_array($admin);
$admin[pass] = $admin[password];
}

if(!$admin[id]){

echo "<html>
<head>
  <title>Admin Control Panel Login</title>
</head>
  <link type='text/css' rel='stylesheet' href='./css/menu.css' />
<body bgcolor='#cccccc' background='./images/bg.gif'>
  <br />
  <br />
  <br />
  <br />
  <form method='POST'>
    <table border='0' cellpadding='5' cellspacing='0' align='center' class='main'>
      <tr>
        <th colspan='2'>Login $failed</th>
      </tr>
      <tr>
        <td colspan='2' style='padding:0px; border-bottom:1px solid #666666; background-color:#ffffff;'>
          <table border='0' cellpadding='0' cellspacing='0' height='70'>
            <tr>
              <td width='170'><img src='./images/logo1.gif' boerder='0'></td>
	<td width='190' align='right'>Elite Gaming Ladder Control Panel v2.0
              </td>
            </tr>
          </table>
        </td>
      </tr>
            <tr>
        <td width='80'>Username:</td>
        <td><input type='text' name='admin[name]' size='50' value='$admin[name]' /></td>
      </tr>
      <tr>
        <td width='80'>Password:</td>
        <td><input type='password' name='admin[pass]' value='' size='50' /></td>
      </tr>
      <tr>
        <td> </td>
        <td align='right'><input type='hidden' name='admin[fail]' value='1'>
<input type='hidden' name='action' value='adminlogin'>
<input type='submit' name='submit' value='Login >>'></td>
      </tr>
    </table>
  </form>
</body>
</html>";
exit;
}
return($admin);
}



//ADMIN MAIN

function admin_main($admin){
global $config;

//Lets Set Some Sessions
$_SESSION['name']=$admin[name]; 
$_SESSION['pass']=$admin[pass]; 
$_SESSION['rights']=$admin[rights]; 

echo "<html>
<head>
  <script type='text/javascript'>
  <!-
  // get out of any containing frameset
  if (self.parent.frames.length != 0) {
    self.parent.location.replace(document.location.href);
  }
  // -->
  </script>
  <title>Elite Gaming Ladder Control Panel</title>
  
  <frameset cols='195,*' framespacing='0' border='0' frameborder='0' frameborder='no' border='0'>
    <frame src='./menu.php' name='frame_nav' id='frame_nav' scrolling='auto' frameborder='0' marginwidth='0' marginheight='0' border='no' />
    <frameset rows='20,*'  framespacing='0' border='0' frameborder='0' frameborder='no' border'0'>
      <frame src='./head.php' name='frame_head' id='frame_head' scrolling='no' noresize='noresize' frameborder='0' marginwidth='10' marginheight='0' border='no' />
      <frame src='./admin.php' name='frame_main' id='frame_main' scrolling='yes' frameborder='0' marginwidth='10' marginheight='10' border='no' />
    </frameset>
  </frameset>
  
  <noframes>
    <body>
      <p>Your browser does not support frames. Please get one that does!</p>
    </body>
  </noframes>
</head>
</html>
";


}



?>

Link to comment
https://forums.phpfreaks.com/topic/71404-solved-login-session-dont-wanna-work/
Share on other sites

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.