Jump to content

[ resolved ] Having a problem with an if statement....again


Seitan

Recommended Posts

Alright, I need help with an if statement, I'm trying to add an admin link to my page, but only for users who have specific user id's....this is what I have so far
[code]if ($_SESSION['user_id'] == '1' OR '2') { echo '<a href="../php/admin.php">Admin</a>';
}[/code]

unfortunately the admin link shows up for everyone, so what am I doing wrong
Here is my session array

[code]  $row = mysql_fetch_array ($result,MYSQL_NUM);
      mysql_free_result($result); mysql_close();
      $_SESSION['user_name'] = $row[1];
      $_SESSION['user_id'] = $row[0];
[/code]

And the if statement doesn't display the admin link at all now
That's how you're putting information into the $_SESSION array.

Just before the "if" statement, add this line:
[code]<?php
echo '<pre>' . print_r($_SESSION,true) . '</pre>;
?>[/code]

This will dump the contents of the $_SESSION array.

Ken

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.