Forum Moderators: coopster

Message Too Old, No Replies

string craziness

         

Gilead

3:12 pm on Nov 21, 2011 (gmt 0)

10+ Year Member



I'm setting up access to the admin page.
I have a session variable indicating if they are an admin, superuser or user.

If they are an admin, show all admin commands; if a superuser, only show superuser commands and if user, redirect them to the user page.

The code so far:
if ($_SESSION['useraccess']) =='Admin' {

echo '<h2>Admin Functions:</h2>';
echo 'Add New Admin<br />';
echo 'View All Admins<br />';
echo 'Update Your Details<br />';
echo 'Ban User<br />';
}
else if ($_SESSION['useracess']) =='SuperUser' {
echo '<h2>Member Functions:</h2>';
echo '<a href="addnewmember.php">Add New User</a><br />';
echo '<a href="importmembers.php">Add Bulk Users(CSV)</a><br />';
echo '<a href="emailuser.php">Email Details to single User</a><br />';
echo '<a href="viewmembers.php">View Users/Delete Users/Modify Users</a><br />';
echo 'Email All Users';
}

// else if ($_SESSION['useraccess']) =='User' {
header("location:http://members/main/index.php");
// }

The trouble is I get a parse error whether I use = or ==
"" or '' or nothing at all. It has to be one of those, but which one?
Parse error: syntax error, unexpected T_IS_EQUAL in path.php on line 27

Thanks!

httpwebwitch

3:53 pm on Nov 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



parentheses...

if ($_SESSION['useracess']) =='SuperUser' {

should be

if ($_SESSION['useracess'] == 'SuperUser') {

rainborick

3:57 pm on Nov 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You're not closing the conditional in your IF statements properly. You should add a closing parenthesis, as in:

if ($_SESSION['useraccess'] == 'Admin') {


And you can't use header() if the page has already sent any output to the user. Good luck!

Gilead

4:03 pm on Nov 21, 2011 (gmt 0)

10+ Year Member



D'OH! I knew it was something simple and silly.
Thanks!