使用会话电子邮件在php中获取用户名

I have created a session of which a user is using email and password to log in, and the session is capturing his/her email, I want to use the email to fetch her other data like first name and last name, I tried to get it but due to my newbie I ended up getting error, here is my login code:

// LOGIN A USER INTO HIS/HER ACCOUNT
if (isset($_POST['login_user'])) {
$email = mysqli_real_escape_string($db, $_POST['email']);
$password = mysqli_real_escape_string($db, $_POST['password']);

if (empty($email)) {
 array_push($errors, "Email is required");
}
if (empty($password)) {
  array_push($errors, "Password is required");
}

if (count($errors) == 0) {
$password = md5($password);
$query = "SELECT * FROM users WHERE email='$email' AND password='$password'";
$results = mysqli_query($db, $query);  
if (mysqli_num_rows($results) == 1) {
  $_SESSION['email'] = $email;
  $_SESSION['success'] = "You are now logged in";
  header('location: index.php');
 }else {
  array_push($errors, "Wrong Email or Password combination");
 }
 }
}

and I figured it to be like the following code below:(which is not actually working)

if($result) {
    if(mysqli_num_rows($result) == 1) {
        //Login Successful
        session_regenerate_id();
        $user = mysqli_fetch_assoc($result);
        $_SESSION['id'] = $user['user_id'];
        $_SESSION['email'] = $user['email'];
        $_SESSION['first_name'] = $user['first_name'];
        $_SESSION['last_name'] = $user['last_name'];
        session_write_close();
        header("location: user_index.php");
        exit();

        else {
            $sql = "SELECT first_name FROM users WHERE email = '" . 
$_SESSION['email'] . "'";
$result = mysqli_query($sql);
$user = mysqli_fetch_array($result);
echo "Hello, " . $user['first_name']";

        }

I found this way to be working, thank you all who tried to help

<?php
include'db.php';

if(isset($_SESSION['email'])){

           $query = "SELECT first_name FROM users WHERE email= '".$_SESSION['email']."'";     

           $result = mysqli_query($db, $query) or 

           die(mysql_error($db)); 

           if (!$result) die('Query failed: ' . mysqli_error($db)); 

           while($row = mysqli_fetch_array($result)){ 

           echo $row['first_name'];

        }

    }
?>