Jump to content

simple login script with sessions not working


scarhand

Recommended Posts

i have no clue why this isnt working

 

if i dont put in the right password i get the error message, but if i do put in the right password it just takes me back to the login screen

 

heres my code:

 

<?php
session_start();

include '../sbxr_connect.php';
include 'header.php';

$adminsql = mysql_query("SELECT * FROM admin") or die(mysql_error());
while($row = mysql_fetch_array($adminsql))
{
 $adminpassword = $row['adminpassword']; 
}



function adminLogin()
{
 global $notify;

?>

<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
<tr>
<td width="100%" height="100%" align="center" valign="middle">

 <table cellpadding="0" cellspacing="0" border="0" width="600" align="center">
 <tr>
 <td width="100%" class="contentbox" align="center">

   <font class="header2">
   admin login
   </font>

   <br />
   <br />

   <?php echo "$notify"; ?>

   <br />
   <br />

   <form method="post">
   <input name="passtry" type="password" maxlength="50" size="30">

   <br />
   <br />

   <input name="login" type="submit" value="Login">
   </form>

 </td>
 </tr>
 </table>

 <br />
 <br />

</td>
</tr>
</table>

<?php
}



function adminIndex()
{
?>

<table cellpadding="0" cellspacing="0" border="0" width="600" align="center">
<tr>
<td width="100%" class="contentbox">

 <center>
 <font class="header2">
 Welcome, admin!
 </font>
 </center>

 <br />

 Welcome to the admin control panel. From here you can change your admin password, configure general options, edit your shoutbox colors and style, edit shouts, ban IP's, add word censors, and more.

 <br />
 <br />

 Please use the menu at the top of this page in order to navigate through your control panel and administer.

</td>
</tr>
</table>

<?php
}



if (isset($_SESSION['adminpassword']))
{
 if ($_SESSION['adminpassword'] == $adminpassword)
 {
   $loggedin = true;
 }
}



if (isset($_POST['login']))
{
 if ($_POST['passtry'] == $adminpassword)
 {
   $_SESSION['adminpassword'] = $adminpassword;
 }
 else
 {
   $notify = "You have entered an invalid admin password, please try again";
 }
}
else
{
 $notify = "Please enter the admin password";
}



if ($loggedin == true)
{
 include 'admin_header.php';

 switch($_GET['edit']) 
 {
   case 'general':
     editGeneral();
     break;

   case 'style':
     editStyle();
     break;

   case 'shouts':
     editShouts();
     break;

   case 'bans':
     editBans();
     break;

   case 'censors':
     editCensors();
     break;

   default:
     adminIndex();

 }

 include 'admin_footer.php';
}
else
{
  adminLogin();
}



include 'footer.php';
?>

 

i know it is successfully getting the password out of the database, but it isnt taking me to the adminIndex page when I've logged in......any help would be greatly appreciated.

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.