title: Get a variable from another page in php
body: <p>I wanted to show the variable username into another page.
  These are the codes I've used.
  This is the first page where the username is inserted.</p>
  
  <pre><code>&lt;?php
  include('login.php'); // Includes Login Script
  if(isset($_SESSION['login_user'])){
  }
  ?&gt; 
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Login&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="login" align="center"&gt;
  &lt;h2&gt;Welcome!&lt;/h2&gt;
  &lt;form action="" method="post"&gt;
  &lt;label&gt;Username :&lt;/label&gt;
  &lt;input id="name" name="username" placeholder="username" type="text"&gt;&lt;br&gt;
  &lt;label&gt;Password :&lt;/label&gt;
  &lt;input id="password" name="password" placeholder="**********" type="password"&gt;&lt;br&gt;&lt;br&gt;
  &lt;input name="submit" type="submit" value=" Login "&gt;
  &lt;span&gt;&lt;?php echo $error; ?&gt;&lt;/span&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Then in this page I wanted to show the username that was inserted</p>
  
  <pre><code>&lt;?php include 'database.php'; ?&gt;
  &lt;?php session_start(); ?&gt;
  &lt;?php
  function visualizza($file) {
  $f = fopen($file, "r"); // apro il file in lettura
  return fread($f, filesize($file));
  fclose($f);
  }
  ?&gt;
  &lt;html&gt;
  &lt;main&gt;
  &lt;div class="container"&gt;
  &lt;h2&gt; Quiz Completato!&lt;/h2&gt;
  &lt;p&gt; Congratulations &lt;?php 
  $username = $_POST['username']; 
  echo $username;
  ?&gt;
  
  ! You completed the test&lt;/p&gt;
  &lt;p&gt;Final Score:&lt;?php echo $_SESSION['score']; ?&gt; &lt;/p&gt;
  &lt;/div&gt;
  &lt;/main&gt;
  </code></pre>
  
  <p>But it tells me Notice: Undefined index: username in C:\xampp\htdocs\quizzer\final.php on line 29
  How can I solve it please?</p>