this is my first time working with sessions, im working on a members area, which i have managed to make but i need some users (admins) to be able to see some links that normal users cant. this is what i have sofar :s
<?php
require_once('auth.php');
?>
<table border='0' cellpadding='0' cellspacing='0' id='memberstitle'>
<tr>
<td background='images/box2_l.png' width='20' height='50'></td>
<td background='images/box2_m.png' height='50'>Welcome <?php echo $_SESSION['SESS_FIRST_NAME'];?>
<table border='0' cellpadding='2' cellspacing='0' id='newsavatar'>
<?php
if(!isset($_SESSION['SESS_AUTH'] == '1') {
echo '<tr>
<td><a href='?p=post'>Post News</a> | <a href="">Post Screenshot</a> | <a href="">View Player List</a></td>
<td rowspan='2' style='vertical-align:middle' width='34' height='34'><img src='images/<?php echo $_SESSION['SESS_AVATAR'];?>'></td>
</tr>
<tr>
<td><a href="?p=logout">Logout</a> | <a href="">Change Password</a> | <a href="">Change Avatar</a></td>
</tr>';
}
else {
echo'<tr>
<td>Control Panel</td>
<td rowspan='2' style='vertical-align:middle' width='34' height='34'><img src='images/<?php echo $_SESSION['SESS_AVATAR'];?>'></td>
</tr>
<tr>
<td><a href="?p=logout">Logout</a> | <a href="">Change Password</a> | <a href="">Change Avatar</a></td>
</tr>';
}
?>
</table>
</td>
<td background='images/box2_r.png' width='20' height='50'></td>
</tr>
</table>
Did you start the session on the beginning of the file?
But even if you did, there are couple more errors in your code:
The
ifshould be more like that:And your ‘echo’ syntax is quite wrong as well:
it in that text without an escape character. So you html attributes
values should be
\'value\'or"value", instead of simple'value'.<?php ?>inside echo. Try string concatenation instead.For example: