Jump to content

Recommended Posts

I have tried many tutorials from google, but just can get it right.

I need a way to create a cookie that keeps the admins logged in...

Any help would be greatly appreciated, heres the file:

 

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



$admin=check_login($admin);


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


function check_login($admin){
global $config;

$sladderid="$admin[ladderid]";
$selected[$sladderid]="SELECTED";

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

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

}

$admin=mysql_query("SELECT * FROM staff WHERE name='$admin[name]' AND password='$admin[pass]' AND ladderid='$admin[ladderid]' AND rights > '0'");
$admin=mysql_fetch_array($admin);

if($admin[ladderid]){
$ladder=mysql_query("SELECT name,isteam FROM ladders WHERE id='$admin[ladderid]'");
$ladder=mysql_fetch_array($ladder);
$admin[laddername]="$ladder[name]";
$admin[isteam]="$ladder[isteam]";
}

$admin[pass]="$admin[password]";

if(!$admin[id]){

$ladders=mysql_query("SELECT id,name FROM ladders WHERE active='2' ORDER BY name");
while(list($id,$name)=mysql_fetch_row($ladders)){
$ladderlist.="<option value='$id' $selected[$id]>$name</option>";
}
echo "
<html>
<head>
  <title>Admin Control Panel Login</title>
</head>
  <link type='text/css' rel='stylesheet' href='./css/manage.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</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='195' background='/images/logo_blue_bg.gif'><img src='./images/logo_blue.gif' align='middle' border='0'></td>
              <td width='195' background='/images/logo_blue_bg2.gif'>
                Extreme Gaming Ladder Control Panel v1.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><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;


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>Extreme 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='./home.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/56462-login-session-creating/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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