//codice
<?php
$_CONFIG['host'] = "localhost";
$_CONFIG['user'] = "lightrsm.com";
$_CONFIG['pass'] = "devis10";
$_CONFIG['dbname'] = "lightrsm_com";
$_CONFIG['table_sessioni'] = "sessioni";
$_CONFIG['table_utenti'] = "utenti";
$_CONFIG['expire'] = 60;
$_CONFIG['regexpire'] = 24; //in ore
$_CONFIG['check_table'] = array(
"username" => "check_username",
"password" => "check_global",
"name" => "check_global",
"surname" => "check_global",
"indirizzo" => "check_global",
"occupazione" => "check_global",
"mail" => "check_global"
);
function check_username($value){
global $_CONFIG;
$value = trim($value);
if($value == "")
return "Il campo non può essere lasciato vuoto";
$query = mysql_query("
SELECT id
FROM ".$_CONFIG['table_utenti']."
WHERE username='".$value."'");
if(mysql_num_rows($query) != 0)
return "Nome utente già utilizzato";
return true;
}
function check_global($value){
global $_CONFIG;
$value = trim($value);
if($value == "")
return "Il campo non può essere lasciato vuoto";
return true;
}
//--------------
define('AUTH_LOGGED', 99);
define('AUTH_NOT_LOGGED', 100);
define('AUTH_USE_COOKIE', 101);
define('AUTH_USE_LINK', 103);
define('AUTH_INVALID_PARAMS', 104);
define('AUTH_LOGEDD_IN', 105);
define('AUTH_FAILED', 106);
define('REG_ERRORS', 107);
define('REG_SUCCESS', 108);
define('REG_FAILED', 109);
$conn = mysql_connect($_CONFIG['host'], $_CONFIG['user'], $_CONFIG['pass']) or die('Impossibile stabilire una connessione');
mysql_select_db($_CONFIG['dbname']);
?>
//fine codice
Questo è il codice php che va incluso nelle pagine con accesso privato,naturalmente con questo codice ogni utente può entrare in qualsiasi pagina di altro utente che si è registrato sul sito,infatti ho creato un area privata chiamata area.php?name=(nome utente) in cui vengono visualizzati i dati dell'utente,ora come posso modificare il codice per impedire che un utente loggato con il suo user e il suo name possa entrare senza restrizioni nelle aree altrui???
Grazie mille![]()