Hello ppl
Well I'm having either mental problems or something, but I'm royally confused.
I'm trying to make a simple login script for Admin/Mods.
Simple, here it is:
Demo to see if it works.
<?php
session_start();
if (isset($_SESSION['Mod'])){
echo "Mod";
}else{
if (isset($_SESSION['Admin'])){
echo "Admin";
}else{
echo "Login";
}
}
?>
Login 2 (Creates session)
case 'login2':
session_start();
$password = $_POST['password'];
$sql = "SELECT * FROM passwords WHERE Admin='$password'";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
if($count==1){
$_SESSION['Admin'] = 'Admin';
echo "<center>Logged in as Administrator</center>";
?>
<meta http-equiv="REFRESH" content="0;url=index.php"></HEAD>
<?php
}else{
$sql2="SELECT * FROM passwords WHERE Moderator='$password'";
$result2 = mysql_query($sql2);
$count2 = mysql_num_rows($result2);
if($count2==1){
$_SESSION['Mod'] = 'Mod';
echo "<center>Logged in as Moderator</center>";
?>
<meta http-equiv="REFRESH" content="0;url=index.php"></HEAD>
<?php
}else{
echo "<center>Wrong password!</center>";
}
}
break;
Now I have a little story you see.
I posted a few days ago that I was having problems with session (on another forum), I was using the wrong Session code thingies, I changed it around and it worked GREAT 100%. Considering the code is on another forum I decided not to save it and if anything went wrong I can just start from there again, Which it did.
I started working on it today, and the code didn't work, every time i typed the correct password, It says it logged me in, the button demo says Login () when it should say Logout (Admin/Mod). So I thought maybe I changed something that i forgot? Changed it to the code from the forums that was working days before, and it STILL doesn't work, even with the correct code.
So unless i'm going mental or insane, can someone help?
Cheers.