Hey. I'm having troubles with this admin session. <?php if ($_SESSION['admin'] == "$admin" ) { echo "IP Address"; }else echo "none"; ?> PHP: But even when I'm logged out it will show "Ip Address" when it should show "none" Anyone know the problem? Thanks
Try this: <?php session_start(); if ($_SESSION['admin'] == $admin ) { echo "IP Address"; } else { echo "none"; } ?> PHP:
//When you logout you must unset($_SESSION['admin']) if ($_SESSION['admin'] == $admin ){ echo "IP Address"; } else { echo "none"; } PHP:
You see, It thinks I'm an admin when I'm logged out so this script is right, But something else is wrong. Anyone know?
members.php <style type="text/css"> <!-- .style1 { font-size: 18px; font-weight: bold; } --> </style> <div id="container"> <?php include("config.php"); include("include/menu.php"); ?> <div id="content"> </h1> <div align="left"><span class="style1">Octi-Might Members </h1> </span><br /> <strong>Username / Email / Group / Age / Joined / <?php $admin = 'root'; $_SESSION['admin'] = 'root'; if ($_SESSION['admin'] == $admin ){ echo "IP Address"; } else { echo "none"; } ?></strong><br><br /> <?php $result = mysql_query("SELECT * FROM members"); while($row = mysql_fetch_array( $result )) { echo $row['username']; echo " - "; echo $row['email']; echo "<hr>"; } ?> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> </div> PHP: config.php <?php session_start(); mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("maindb") or die(mysql_error()); if($_SESSION['username']) $result = mysql_query("UPDATE `online` SET `online`='yes' WHERE $id='$id'"); $result = mysql_query("SELECT groupname FROM members WHERE username='$username'"); $row = mysql_fetch_assoc($result); // The results are stored in an sql result array -we need to extract them $groupname = $row['groupname']; // Since we extracted it into an array, get the correct index of the array if ($_SESSION['admin'] == $admin ) { } if ($groupname == "$guest" ) { } else { if ($groupname == "$user" ) { }else { if ($groupname == "$admin" ) { }else { if ($groupname == "$moderator" ) { }else { } } } } ?> PHP:
Sorry, here is the part in members.php if ($_SESSION['admin'] == $admin ){ echo "IP Address"; } else { echo "none"; }
I think you should initialize the variable $admin=root, in a common file like config.php so that all file can access the variable. Thanks Samir