Ciao a tutti 
Il mio problema è questo: ho un CMS in cui si entra normalmente inserendo login e password.
Per gestire l'accesso ho usato uno script preso dalla raccolta script di html.it (Page Password Protect http://php.html.it/script/vedi/4210/...ssword-protect )
Vi riporto il codice:
	Codice PHP:
	
<?php
##################################################################
#  SETTINGS START
##################################################################
// Add login/password pairs below, like described above
// NOTE: all rows except last must have comma "," at the end of line
$LOGIN_INFORMATION = array(
  'admin' => 'adminpsw',
  'user' => 'userpsw'
);
//$LOGIN_INFORMATION[] = $row;
// request login? true - show login and password boxes, false - password box only
define('USE_USERNAME', true);
// User will be redirected to this page after logout
define('LOGOUT_URL', 'index.php');
// time out after NN minutes of inactivity. Set to 0 to not timeout
define('TIMEOUT_MINUTES', 15);
// This parameter is only useful when TIMEOUT_MINUTES is not zero
// true - timeout time from last activity, false - timeout time from login
define('TIMEOUT_CHECK_ACTIVITY', true);
##################################################################
#  SETTINGS END
##################################################################
///////////////////////////////////////////////////////
// do not change code below
///////////////////////////////////////////////////////
// show usage example
if(isset($_GET['help'])) {
  die('Includi questa riga di codice all\'inizio di ogni pagina che vuoi proteggere:
<?php include("' . str_replace('\\','\\\\',__FILE__) . '"); ?>');
}
// timeout in seconds
$timeout = (TIMEOUT_MINUTES == 0 ? 0 : time() + TIMEOUT_MINUTES * 60);
// logout?
if(isset($_GET['logout'])) {
  setcookie("verify", '', $timeout, '/'); // clear password;
  header('Location: ' . LOGOUT_URL);
  exit();
}
if(!function_exists('showLoginPasswordProtect')) {
// show login form
function showLoginPasswordProtect($error_msg) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>Pagina di accesso</title>
</head>
<body>
<div id="container">
                <div id="banner">
                [img]img/banner.jpg[/img]
                 </div>
                 <div id="menu">
                 </div>
                 <div id="content">
                 <h2>Accesso al pannello di amministrazione</h2>
                <form method="post">
                <fieldset>
                <legend>Inserire le credenziali d'accesso</legend>
    
    <font color="red"><?php echo $error_msg; ?></font>
<?php if (USE_USERNAME) echo '<label for="access_login">Login:</label>
<input type="input" name="access_login" />
<label for="access_password">Password:</label>
 '; ?><input type="password" name="access_password" /></fieldset><fieldset class="submit"><input type="submit" name="Submit" value="Entra" /></fieldset>
  </form>
  
  </div>
  </body>
</html>
<?php
  // stop at this point
  die();
}
}
// user provided password
if (isset($_POST['access_password'])) {
  $login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
  $pass = $_POST['access_password'];
  if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION)
  || (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) ) 
  ) {
    showLoginPasswordProtect("Dati inseriti non corretti");
  }
  else {
    // set cookie if password was validated
    setcookie("verify", md5($login.'%'.$pass), $timeout, '/');
    
    // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
    // So need to clear password protector variables
    unset($_POST['access_login']);
    unset($_POST['access_password']);
    unset($_POST['Submit']);
  }
}
else {
  // check if password cookie is set
  if (!isset($_COOKIE['verify'])) {
    showLoginPasswordProtect("");
  }
  // check if cookie is good
  $found = false;
  foreach($LOGIN_INFORMATION as $key=>$val) {
    $lp = (USE_USERNAME ? $key : '') .'%'.$val;
    if ($_COOKIE['verify'] == md5($lp)) {
      $found = true;
      // prolong timeout
      if (TIMEOUT_CHECK_ACTIVITY) {
        setcookie("verify", md5($lp), $timeout, '/');
      }
      break;
    }
  }
  if (!$found) {
    showLoginPasswordProtect("");
  }
}
?>
 
Per proteggere una pagina basta richiamare questa con un include.
Io vorrei però che per utenti diversi fosse riservato l'accesso a diverse aree del sito.
Nella condizione in cui è ora, il codice da un accesso identico sia a "admin" che a "user". Io vorrei che se "user" cerca di entrare ad esempio in un'area di amministrazione ricevesse un messaggio del tipo "Non hai i privilegi per accedere a questa pagina".
Come posso fare? Qual è il codice che devo aggiungere in quelle righe sopra e all'interno delle altre pagine per fare in modo da avere accessi discriminati? Serve una sessione?
Un'altra cosa.
I dati di accesso, come mostrato, sono inclusi direttamente all'interno del codice 
	Codice PHP:
	
// Add login/password pairs below, like described above
// NOTE: all rows except last must have comma "," at the end of line
$LOGIN_INFORMATION = array(
  'admin' => 'adminpsw',
  'user' => 'userpsw'
); 
 
Come potrei fare se invece volessi richiamare i dati da database, considerando di avere una tabella UTENTI con campi ID, USER e PSW?
Grazie dell'aiuto! 