title: javascript function is supposed to display php SESSION data but isn't called
body: <p>I'm trying to make a regular old registration form for a website; and I'm trying to display the name of the logged-in user(if any) at the top of the page. However, the function that is supposed to update that field doesn't seem o be called at all, and I can't make heads or tails of it, nor of the error messages my console displays:
  "Uncaught SyntaxError: Unexpected token &lt; -- pagina_registrazione.php:36"
  "Uncaught ReferenceError: update_name is not defined 
       onload                               -- pagina_registrazione.php:10"</p>
  
  <p>here is the code:</p>
  
  <pre><code>&lt;?php
      require './config_db.php';
  ?&gt;
  &lt;!DOCTYPE HTML&gt;
  &lt;html  lang = "it" &gt;
      &lt;head&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;meta name = "keywords" content = "catcher, profilo, registrazione, utente"&gt;
          &lt;meta name="author" content="Luca Ballarati"&gt;
          &lt;link rel="stylesheet" href="./../stile/sottopagine.css" type="text/css" media="screen"&gt;
          &lt;title&gt;pagina di registrazione&lt;/title&gt;
      &lt;/head&gt;
      &lt;body onload=update_name&gt;
          &lt;section&gt;
              &lt;p id="spia_connessione"&gt;NOMEUTENTEQUI&lt;/p&gt;
              &lt;p&gt;Se hai già un'account &lt;a href = "./pagina_login.php"&gt;&lt;strong&gt;clicca qui&lt;/strong&gt;&lt;/a&gt; per accedere.&lt;/p&gt;
              &lt;p&gt;Altrimenti &lt;strong&gt;registrati&lt;/strong&gt; compilando i campi qui sotto&lt;/p&gt;
          &lt;/section&gt;
          &lt;div id="login_form"&gt;
              &lt;form name="registra" action="./pagina_registrazione.php" method="post"&gt;
                  &lt;div&gt;
                      &lt;label&gt;&lt;p&gt;Nome Utente&lt;/p&gt;&lt;/label&gt;
                     &lt;input type="text" placeholder="nome_utente" name="username" required autofocus&gt;
                  &lt;/div&gt;
                  &lt;div&gt;
                      &lt;label&gt;&lt;p&gt;Password&lt;/p&gt;&lt;/label&gt;
                      &lt;input type="password" placeholder="password" name="password" required&gt;
                  &lt;/div&gt;
                  &lt;div&gt;
                      &lt;label&gt;&lt;p&gt;Conferma Password&lt;/p&gt;&lt;/label&gt;
                     &lt;input type="password" placeholder="conferma_password" name="passwordconfirm" required&gt;
                  &lt;/div&gt;
                  &lt;input name="pulsante_invio" type="submit" value="Invia"&gt;
                  &lt;?php
                      if(isset($_POST['pulsante_invio'])) {
                          $nomeutente = $_POST['username'];
                          $password = $_POST['password'];
                          $cpassword = $_POST['passwordconfirm'];
                          if ($password==$cpassword) {
                              $query = "SELECT * FROM utenti WHERE NomeUtente='$nomeutente'";
                              $esegui_query = mysqli_query($con,$query);
                              if(mysqli_num_rows($esegui_query)&gt;0) {
                                  echo '&lt;script type="text/javascript"&gt;
                                  window.alert("Nome Utente già usato: registrarsi con un diverso Nome Utente");
                                  &lt;/script&gt;';
                              }
                              else {
                                  $query = "INSERT INTO utenti (NomeUtente,Password,Record,Partite)
                                      VALUES('$nomeutente','$password',0,0)";
                                  $esegui_query = mysqli_query($con,$query);
                                  if ($esegui_query) {
                                      $nome = $_SESSION['username'];
                                      //porta l'utente alla pagina di login
                                      echo '&lt;script type="text/javascript"&gt;
                                          window.alert("Utente registrato correttamente");
                                      &lt;/script&gt;';
                                      //echo '&lt;script type="text/javascript"&gt;
                                          //document.getElementById("spia_connessione").innerHTML = "'$nome'";
                                      //&lt;/script&gt;';
                                  }
                                  else {
                                      echo '&lt;script type="text/javascript"&gt;
                                          window.alert("Errore durante la registrazione");
                                          &lt;/script&gt;';
                                  }
                              }
                          }
                          else {
                              echo '&lt;script type="text/javascript"&gt;
                                  window.alert("Password e Password di conferma devono essere uguali");
                              &lt;/script&gt;';
                          }
                      }
                  ?&gt;
               &lt;/form&gt;
          &lt;/div&gt;
          &lt;script type="text/javascript"&gt;
              function update_name() {
                  window.alert("nome utente aggiornato");
                  var nm = &lt;?php echo $_SESSION['username']; ?&gt;;
                  document.getElementById("spia_connessione").innerHTML = nm;
              }
          &lt;/script&gt;
      &lt;/body&gt;
  </code></pre>