vorrei che nell'index compaia il nome di chi è loggato.
check.php:
	Codice PHP:
	
<?php
@session_start();
if (!session_is_registered('autorizzato')) {
    echo "
Effettua il login</p>";
    echo '[url="index.php"]Home[/url] | ';
    echo '[url="login.php"]Login[/url]';
    die;
}
?>
 
login.php:
	Codice PHP:
	
<?php
@session_start();
if (session_is_registered('autorizzato')) {
    echo "
Effettua il logout</p>";
    echo '[url="logout.php"]Logout[/url]';
    die;
}
?>
<?php
include_once 'config.php';
$link = mysql_connect($host, $user, $password) or die("Non è possibile connettersi al server
");
$conn = mysql_select_db($db, $link) or die("Non è possibile connettersi al db
");
session_start();
if (isset($_POST['invio'])) {
    $user = mysql_real_escape_string($_POST['user']);
    $pass = mysql_real_escape_string($_POST['pass']);
    $query = "select * from utenti where nome='" . $user . "' and password='" . $pass . "'";
    $result = mysql_query($query, $link) or die(mysql_error($link));
    $riga = mysql_fetch_row($result);
    if ($riga[0] != $user || $riga[0] == "") {
        $destinazione = "destroy.php";
    } else {
        if ($riga[1] == $pass) {
            session_register('autorizzato');
            $_SESSION["autorizzato"] = $user;
            $destinazione = "index.php";
        } else {
            $destinazione = "destroy.php";
        }
    }
    echo '<script language="javascript">document.location.href="' . $destinazione . '"</script>';
} else {
?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Login</title>
        </head>
        <body>
            [url="index.php"]Home[/url]
            <form method="post" name="inserisci" action="#">
                <table>
                    <tr>
                        <td>User:</td>
                        <td><input type="text" name="user" /></td>
                    </tr>
                    <tr>
                        <td>Password:</td>
                        <td><input type="password" name="pass" /></td>
                    </tr>
                    <tr>
                        <td><input type="submit" name="invio" value="Invio" /></td>
                    </tr>
                </table>
            </form>
        <?php
        if ($_GET['err'] == 1) {
            echo "Login errato";
            echo "
";
        }
        ?>
    </body>
</html>
<?php
    }
?>
 
pensavo bastasse mettere questo:
	Codice PHP:
	
<?php
@session_start();
if (session_is_registered('autorizzato')) {
    echo "
Benvenuto " . $_SESSION['autorizzato'] . '</p>[url="logout.php"]Logout[/url]';
} 
?>
 
ma nn ha funzionato.
come faccio a fargli scrivere il nome dell'utente?