With what bit do you need help? 100 odd lines of code - can you whittle it down a bit?
diafol
Keep Smiling
10,654 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57
For me a simple solution works off the session variable ($_SESSION['user_level']).
If an user is logged in, they should see their own profile page (including the admin user) - this works off $_SESSION['user_id']. This is only set when an user/admin has logged in.
The $_SESSION['user_level'] could hold an integer like 1 = regular user, 2 = admin, 3 = superadmin etc.
You may find that a separate page would serve as a place to edit all users. This could be placed in an admin nav item, which is only visible if the $_SESSION['user_level'] > 1. Also that page would be protected from direct access, like:
if(!isset($_SESSION['user_level']) || $_SESSION['user_level'] < 2){
header('index.php');
exit;
}
The table code you posted looks ok to me.
diafol
Keep Smiling
10,654 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57
sorry:
header('Location: index.php');
exit;
diafol
Keep Smiling
10,654 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57
If this in in the index.php, then you don't want to redirect to the index.php as you may get an infinite redirect loop.
diafol
Keep Smiling
10,654 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57
Ok, mark thread as solved.
diafol
Keep Smiling
10,654 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57
Again, down to session variable.
You could set up a profiles page where the profile showed is the one in the url querystring (similar to Daniweb). Only when the user id in the querystring is equal to the session user id (or if the user is an admin), do you make it editable.
diafol
Keep Smiling
10,654 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57