I've been struggling the past couple days to create the routine that Larry mentions on page 575 of Chapter 13 to set up Site Administration.
I added the "administrator" column as an unsigned TINYINT and assigned the users I want as administrators with 1 and 0 for all common users.
This is the code I've tried in the footer.html:
<?php # Script 13.2 - footer.html
// This page completes the HTML template
// Display links based upon the login status.
// Show LOGIN links if this is the LOGOUT page.
if (isset($_SESSION['user_id']) AND ($_GET['administrator'] == 1) AND (substr($_SERVER['PHP_SELF'], -10) != 'logout.php')) {
echo '<a href="logout.php">Logout</a><br />
<a href="change_password.php">Change Password</a><br />
<a href="view_users.php"</a><br />
';
} elseif (isset($_SESSION['user_id']) AND ($_GET['administrator'] == 0) AND (substr($_SERVER['PHP_SELF'], -10) != 'logout.php')) {
echo '<a href="logout.php">Logout</a><br />
<a href="change_password.php">Change Password</a><br />
';
} else { // Not logged in.
echo '<a href="register.php">Register</a><br />
<a href="login.php">Login</a><br />
<a href="forgot_password.php">Forgot Password</a><br />
';
}
?>
From a syntax perspective, I don't see any errors, but obviously it doesn't work. I get an "undefined index: administrator" error.
I want the administrators to see view_users.php and edit_user.php, etc.