[PHP] Visualizzare utente dopo login

l.chiabrera

Nuovo Utente
4 Nov 2018
3
0
1
salve a tutti
un utente, dopo il login, viene reindirizzato alla pagina 'index.php'...e fin qui tutto bene.
Come posso visualizzare 'user_name' dell'utente in index.php?
con questo codice mi da errore...
PHP:
<?php
//index.php
include('database_connection.php');

if(!isset($_SESSION["user_id"]))
{
    $user_name = $_SESSION['user_name'] ;
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <title>PHP Register Login Script with Email Verification</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<br />
<br />
<h1 align="center">PHP Register Login Script with Email Verification</h1>

<h3 align="center">Welcome Verified <?php echo $user_name ?> Email User</h3>

<h4 align="center"><a href="logout.php">Logout</a></h4>

</body>

</html>
l''errore è qui:
PHP:
[Error] Notice: Undefined variable: user_name in C: xampp htdocs email_address index.php on line 36
(<h3 align = "center"> Welcome Verified <? php echo $ user_name?> Email User </h3>)