Zepo. Posted October 1, 2007 Share Posted October 1, 2007 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> "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/71404-solved-login-session-dont-wanna-work/ Share on other sites More sharing options...
darkfreaks Posted October 1, 2007 Share Posted October 1, 2007 for one the logout doesnt work properly is this what your on about? Quote Link to comment https://forums.phpfreaks.com/topic/71404-solved-login-session-dont-wanna-work/#findComment-359384 Share on other sites More sharing options...
marcus Posted October 1, 2007 Share Posted October 1, 2007 http://eliteladders.com/devlopment/admincp/includes/ ^^ shouldn't keep that public Quote Link to comment https://forums.phpfreaks.com/topic/71404-solved-login-session-dont-wanna-work/#findComment-359385 Share on other sites More sharing options...
darkfreaks Posted October 1, 2007 Share Posted October 1, 2007 LOL i didnt notice that but his logout doesnt log you out unless you click twice on it Quote Link to comment https://forums.phpfreaks.com/topic/71404-solved-login-session-dont-wanna-work/#findComment-359387 Share on other sites More sharing options...
marcus Posted October 1, 2007 Share Posted October 1, 2007 For your logout you should just make a separate page, check if the session exists, if it does called session destroy. Quote Link to comment https://forums.phpfreaks.com/topic/71404-solved-login-session-dont-wanna-work/#findComment-359389 Share on other sites More sharing options...
Zepo. Posted October 1, 2007 Author Share Posted October 1, 2007 Im talking about logins, and the auto login isnt working. The problem is that the sessions terminate themselves after running the autologin once... I havnt made the logout yet. Quote Link to comment https://forums.phpfreaks.com/topic/71404-solved-login-session-dont-wanna-work/#findComment-359390 Share on other sites More sharing options...
marcus Posted October 1, 2007 Share Posted October 1, 2007 Well duh, you're recreating the session by calling the value again. Quote Link to comment https://forums.phpfreaks.com/topic/71404-solved-login-session-dont-wanna-work/#findComment-359396 Share on other sites More sharing options...
Zepo. Posted October 1, 2007 Author Share Posted October 1, 2007 Ohhh sorry for being a noob still learning, that makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/71404-solved-login-session-dont-wanna-work/#findComment-359401 Share on other sites More sharing options...
marcus Posted October 1, 2007 Share Posted October 1, 2007 No noob can learn You're just new to PHP, you're excelling. Quote Link to comment https://forums.phpfreaks.com/topic/71404-solved-login-session-dont-wanna-work/#findComment-359407 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.