Zepo. Posted June 20, 2007 Share Posted June 20, 2007 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 More sharing options...
Zepo. Posted June 20, 2007 Author Share Posted June 20, 2007 Anyone? Please? Link to comment https://forums.phpfreaks.com/topic/56462-login-session-creating/#findComment-278896 Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 http://www.php.net/set_cookie Link to comment https://forums.phpfreaks.com/topic/56462-login-session-creating/#findComment-278911 Share on other sites More sharing options...
Zepo. Posted June 20, 2007 Author Share Posted June 20, 2007 Actually sessions look better, how could i do that... Link to comment https://forums.phpfreaks.com/topic/56462-login-session-creating/#findComment-278920 Share on other sites More sharing options...
corbin Posted June 21, 2007 Share Posted June 21, 2007 I suggest reading up on sessions from of course the PHP site and maybe some tutorials as well. After a quick search, I found http://www.tizag.com/phpT/phpsessions.php which looks like it explains things fairly well. Link to comment https://forums.phpfreaks.com/topic/56462-login-session-creating/#findComment-278938 Share on other sites More sharing options...
Zepo. Posted June 21, 2007 Author Share Posted June 21, 2007 I read that but i have no clue on how to make that into where it keeps you logged in... Link to comment https://forums.phpfreaks.com/topic/56462-login-session-creating/#findComment-278960 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.