PHP Get username from Database, display username on page
<p>I am currently trying to get the username from my database into my webpage and display it. I am not having much luck, this is the code that I have so far. Should work, but the $username variable is undefined, not sure why.</p>

<pre><code>        &lt;?php
    /* Database Information */
    $server = '127.0.0.1';
    $database = 'nicedevelopment';
    $dbuser = 'root';

    /* Database Connection */
    $connect = mysql_connect("$server", "$dbuser")
        OR die(mysql_error());
    mysql_select_db("$database", $connect);

    /* Escape String */
    $username = mysql_real_escape_string($connect);

    /* Find and get row*/
    $getit = mysql_query("SELECT * FROM users WHERE username='$username'",$connect);
    $row = mysql_fetch_array($getit);

    $username = $row['username']
        ?&gt;

  &lt;nav&gt;
    &lt;div class="nav-wrapper"&gt;
      &lt;a href="#" class="brand-logo center"&gt;&lt;?php echo $row['username']; ?&gt;&lt;/a&gt;
</code></pre>

<p><strong>This is my login page!</strong></p>

<pre><code>    &lt;?php
 require('connect.php');
    session_start();
    // If form submitted, insert values into the database.
        if (isset($_POST['email'])){
        $email = $_POST['email'];
            $password = $_POST['password'];
        $email = stripslashes($email);
        $email = mysql_real_escape_string($email);
        $password = stripslashes($password);
        $password = mysql_real_escape_string($password);
        //Checking is user existing in the database or not
        $query = "SELECT * FROM `users` WHERE email='$email' and password='".md5($password)."'";
        $result = mysql_query($query) or die(mysql_error());
        $rows = mysql_num_rows($result);
        if($rows==1){
        $_SESSION['email'] = $email;
        header("Location: dashboard.php"); // Redirect user to index.php
    }else{
    echo "&lt;div class='form'&gt;&lt;h4&gt;Email/password is incorrect.&lt;/h4&gt;&lt;br/&gt;Click here to &lt;a href='index.php'&gt;Login&lt;/a&gt;&lt;/div&gt;";
  }
    }else{
?&gt;
</code></pre>