io ho questo script per il login
access-denied.php:
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title>Access Denied</title>
<
link href="loginmodule.css" rel="stylesheet" type="text/css" />
</
head>
<
body>
<
h1>Accesso negato </h1>
<
p align="center"></p>
<
h4 align="center" class="err">Accesso negato 

  Non hai i permessi per accedere
</h4>
</
body>
</
html
auth.php:
Codice PHP:
<?php
    
//Start session
    
session_start();
    
    
//Verifico l´esistenza dell´utente
    
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
        
header("location: access-denied.php");
        exit();
    }
?>
config.php:
Codice PHP:
<?php
    define
('DB_HOST''localhost');
    
define('DB_USER''***');
    
define('DB_PASSWORD''******');
    
define('DB_DATABASE''my_*****');
?>
login-exec.php:
Codice PHP:
<?php
    
//Start session
    
session_start();
    
    
//Include database connection details
    
require_once('config.php');
    
    
//Array to store validation errors
    
$errmsg_arr = array();
    
    
//Validation error flag
    
$errflag false;
    
    
//Connect to mysql server
    
$link mysql_connect(DB_HOSTDB_USERDB_PASSWORD);
    if(!
$link) {
        die(
'Failed to connect to server: ' mysql_error());
    }
    
    
//Select database
    
$db mysql_select_db(DB_DATABASE);
    if(!
$db) {
        die(
"Unable to select database");
    }
    
    
//Function to sanitize values received from the form. Prevents SQL injection
    
function clean($str) {
        
$str = @trim($str);
        if(
get_magic_quotes_gpc()) {
            
$str stripslashes($str);
        }
        return 
mysql_real_escape_string($str);
    }
    
    
//Sanitize the POST values
    
$login clean($_POST['login']);
    
$password clean($_POST['password']);
    
    
//Input Validations
    
if($login == '') {
        
$errmsg_arr[] = 'Login ID persa';
        
$errflag true;
    }
    if(
$password == '') {
        
$errmsg_arr[] = 'Password persa';
        
$errflag true;
    }
    
    
//If there are input validations, redirect back to the login form
    
if($errflag) {
        
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
        
session_write_close();
        
header("location: login-form.php");
        exit();
    }
    
    
//Create query
    
$qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'";
    
$result=mysql_query($qry);
    
    
//Check whether the query was successful or not
    
if($result) {
        if(
mysql_num_rows($result) == 1) {
            
//Login Successful
            
session_regenerate_id();
            
$member mysql_fetch_assoc($result);
            
$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
            
$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
            
$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
            
session_write_close();
            
header("location: member-index.php");
            exit();
        }else {
            
//Login failed
            
header("location: login-failed.php");
            exit();
        }
    }else {
        die(
"Query failed");
    }
?>
login-failed.php:
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title>Login Failed</title>
<
link href="loginmodule.css" rel="stylesheet" type="text/css" />
</
head>
<
body>
<
h1>Login fallito</h1>
<
p align="center"></p>
<
h4 align="center" class="err">Login Fallito

  Controlla la tua username e
/o la tua password</h4>
</
body>
</
html
login-form.php:
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title>Login Form</title>
<
link href="loginmodule.css" rel="stylesheet" type="text/css" />
</
head>
<
body>


</
p>
<
form id="loginForm" name="loginForm" method="post" action="login-exec.php">
  <
table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
    <
tr>
      <
td width="112">[b]Login[/b]</td>
      <
td width="188"><input name="login" type="text" class="textfield" id="login" /></td>
    </
tr>
    <
tr>
      <
td>[b]Password[/b]</td>
      <
td><input name="password" type="password" class="textfield" id="password" /></td>
    </
tr>
    <
tr>
      <
td></td>
      <
td><input type="submit" name="Submit" value="Login" /></td>
    </
tr>
  </
table>
</
form>
</
body>
</
html
loginmodule.css: (anche se nn é obbligatorio)
Codice PHP:
body {
    
font11px VerdanaArialHelveticasans-serif;
    
color#666666;
    
margin0px;
    
padding20px 10px 0px;
}
.
textfield {
    
font-size11px;
    
color#333333;
    
background#F7F7F7;
    
border1px solid #CCCCCC;
    
padding-left1px;
}
h1 {
    
color#99CC00;
    
margin0px 0px 5px;
    
padding0px 0px 3px;
    
fontbold 18px VerdanaArialHelveticasans-serif;
    
border-bottom1px dashed #E6E8ED;
}
{
    
color#2D3954;
    
font-size11px;
}
a:hover {
    
color#99CC00;
}
.
err {
    
color#FF9900;
}
th {
    
font-weightbold;
    
text-alignleft;

logout.php:
Codice PHP:
<?php
    
//Start session
    
session_start();
    
    
//Unset the variables stored in session
    
unset($_SESSION['SESS_MEMBER_ID']);
    unset(
$_SESSION['SESS_FIRST_NAME']);
    unset(
$_SESSION['SESS_LAST_NAME']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Logged Out</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Logout </h1>
<p align="center"></p>
<h4 align="center" class="err">logout eseguito</h4>
<p align="center">clicca qui per il [url="login-form.php"]Login[/url]</p>
</body>
</html>
member-index.php:
Codice PHP:
<?php
    
require_once('auth.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Index</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Benvenuto <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1>
[url="member-profile.php"]I miei progetti[/url] | [url="logout.php"]Logout[/url]


Home</p>
</body>
</html>
member-profile.php:
Codice PHP:
<?php
    
require_once('auth.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My Profile</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>I miei progetti</h1>
[url="member-index.php"]Home[/url] | [url="logout.php"]Logout[/url]


Questa &egrave; una pagina riservata </p>
</body>
</html>
register-exec.php:
Codice PHP:
<?php
    
//Start session
    
session_start();
    
    
//Include database connection details
    
require_once('config.php');
    
    
//Array to store validation errors
    
$errmsg_arr = array();
    
    
//Validation error flag
    
$errflag false;
    
    
//Connect to mysql server
    
$link mysql_connect(DB_HOSTDB_USERDB_PASSWORD);
    if(!
$link) {
        die(
'Failed to connect to server: ' mysql_error());
    }
    
    
//Select database
    
$db mysql_select_db(DB_DATABASE);
    if(!
$db) {
        die(
"Unable to select database");
    }
    
    
//Function to sanitize values received from the form. Prevents SQL injection
    
function clean($str) {
        
$str = @trim($str);
        if(
get_magic_quotes_gpc()) {
            
$str stripslashes($str);
        }
        return 
mysql_real_escape_string($str);
    }
    
    
//Sanitize the POST values
    
$fname clean($_POST['fname']);
    
$lname clean($_POST['lname']);
    
$login clean($_POST['login']);
    
$password clean($_POST['password']);
    
$cpassword clean($_POST['cpassword']);
    
    
//Input Validations
    
if($fname == 'bill') {
        
$errmsg_arr[] = 'tu non ti chiami bill gates';
        
$errflag true;
    }
    if(
$lname == 'gates') {
        
$errmsg_arr[] = 'sisi e io sono tua nonna XDDDD';
        
$errflag true;
    }
    if(
$login == '') {
        
$errmsg_arr[] = 'Non hai inserito la tua login id';
        
$errflag true;
    }
    if(
$password == '') {
        
$errmsg_arr[] = 'Non hai inserito la tua password';
        
$errflag true;
    }
    if(
$cpassword == '') {
        
$errmsg_arr[] = 'Non hai la conferma password';
        
$errflag true;
    }
    if( 
strcmp($password$cpassword) != ) {
        
$errmsg_arr[] = 'Le password non corrispondono';
        
$errflag true;
    }
    
    
//Check for duplicate login ID
    
if($login != '') {
        
$qry "SELECT * FROM members WHERE login='$login'";
        
$result mysql_query($qry);
        if(
$result) {
            if(
mysql_num_rows($result) > 0) {
                
$errmsg_arr[] = 'Login ID already in use';
                
$errflag true;
            }
            @
mysql_free_result($result);
        }
        else {
            die(
"Query failed");
        }
    }
    
    
//If there are input validations, redirect back to the registration form
    
if($errflag) {
        
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
        
session_write_close();
        
header("location: register-form.php");
        exit();
    }

    
//Create INSERT query
    
$qry "INSERT INTO members(firstname, lastname, login, passwd) VALUES('$fname','$lname','$login','".md5($_POST['password'])."')";
    
$result = @mysql_query($qry);
    
    
//Check whether the query was successful or not
    
if($result) {
        
header("location: register-success.php");
        exit();
    }else {
        die(
"Query failed");
    }
?>
register-form.php:
Codice PHP:
<?php
    session_start
();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login Form</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
    
if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >) {
        echo 
'<ul class="err">';
        foreach(
$_SESSION['ERRMSG_ARR'] as $msg) {
            echo 
'[*]',$msg,''
        }
        echo 
'[/list]';
        unset(
$_SESSION['ERRMSG_ARR']);
    }
?>
<form id="loginForm" name="loginForm" method="post" action="register-exec.php">
  <table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
    <tr>
      <th>Nome (non obligatorio)</th>
      <td><input name="fname" type="text" class="textfield" id="fname" /></td>
    </tr>
    <tr>
      <th>cognome (non obligatorio)</th>
      <td><input name="lname" type="text" class="textfield" id="lname" /></td>
    </tr>
    <tr>
      <th width="124">Login id (username)</th>
      <td width="168"><input name="login" type="text" class="textfield" id="login" /></td>
    </tr>
    <tr>
      <th>Password</th>
      <td><input name="password" type="password" class="textfield" id="password" /></td>
    </tr>
    <tr>
      <th>Ripeti password </th>
      <td><input name="cpassword" type="password" class="textfield" id="cpassword" /></td>
    </tr>
    <tr>
      <td></td>
      <td><input type="submit" name="Submit" value="Register" /></td>
    </tr>
  </table>
</form>
</body>
</html>
register-success.php:
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title>Registration Successful</title>
<
link href="loginmodule.css" rel="stylesheet" type="text/css" />
</
head>
<
body>
<
h1>Registrazione completata</h1>


[
url="login-form.php"]Clicca qui[/url]per loggarti</p>
</
body>
</
html
Peró ogni utente avrá la stessa pagina...
Io invece vorrei che ogni utente avesse la stessa pagina e puó personalizzarla come vuole