title: Login page to show "welcome user" on index.php
body: <p>I created login page and everything works, but redirects me to a new page saying i wrote in ECHO, but i want it to show it in index.php with sign in upper right corner "Welcome USERNAME". Like on facebook when you login it says "WELCOME USER"</p>
  
  <p>Here is index.php</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
  
      &lt;title&gt;NAME&lt;/title&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/login.css"/&gt;
      &lt;meta name=viewport content="width=device-width, initial-scale=1"&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id="login"&gt;
          &lt;h1&gt;Welcome to NAME&lt;/h1&gt;
          &lt;h2&gt;LOGIN OR REGISTER&lt;br/&gt;TO CONTINUE&lt;/h2&gt;
          &lt;form action="login.php" method="POST" class="input"&gt;
  
              &lt;label for="username"&gt;Username&lt;/label&gt;&lt;br/&gt;
              &lt;input type="text" name="username"&gt; &lt;br/&gt;
  
              &lt;label for="password"&gt;Password&lt;/label&gt;&lt;br/&gt;
              &lt;input type="password" name="password"&gt; &lt;br/&gt;
  
              &lt;input type="submit" value="Login"&gt;         
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>and here is login.php</p>
  
  <pre><code>&lt;?php
  session_start();
  
      $username = $_POST ['username'];
      $password = $_POST ['password'];
  
      if ($username&amp;&amp;$password)
      {
          $connect = mysql_connect ("localhost","root","") or die ("Could not connect");
          mysql_select_db ("logintest") or die ("Could not find database");
          $query = mysql_query ("SELECT * FROM users WHERE username='$username'");
          $numrows = mysql_num_rows ($query);
  
          if ($numrows !=0)
          {
  
              while ($row = mysql_fetch_assoc($query))
  
              {
                  $dbusername = $row ["username"];
                  $dbpassword = $row ["password"];
              }
  
          if ($username==$dbusername&amp;&amp;$password==$dbpassword)
              {
                  echo "Welcome USER";
                  $_SESSION ["username"]=$username;
  
              }
              else
                  echo "Incorrect password";
          }
          else
              die ("That user does not exist");
      }
      else
          die("Please enter username and password");
  
  ?&gt;
  </code></pre>