I'm aware that there are many similar questions, I have tried many of them but still doesn't work.
here's my createAccount.php
<?php
session_start();
include("createAccount.html");
if(isset($_POST["createAccount"])) {
    include("Database.php");
    $username = $_POST["username"];
    $email = $_POST["email"];
    $password = $_POST["password"];
    echo $password;
    echo $username;
    $createAccount = "INSERT INTO users" . "(username, email, password)" . "VALUES('$username', '$email', '$password')";
    $checkUsername = "SELECT username FROM users WHERE username='$username'";
    $checkEmail = "SELECT email FROM users WHERE email='$email'";
    $result = $connected->query($checkUsername);
    $emailResults = $connected->query($checkEmail);
    if($result->num_rows == 0) {
        if($emailResults->num_rows==0){
            $connected->query($createAccount);
            //echo "Account Created";
        } else {
            //echo "Email in use";
            $emailInUse = "Email already in use";
            $_SESSION["emailInUse"] = $emailInUse;
        }
    } else {
        echo //"Username already exists";
        $accountExists = "Username already exists";
        $_SESSION["accountExists"] = $accountExists;
    }
}
?>
and here the test.php (to test is sessions are working)
<?php
session_start();
echo $_SESSION["accountExists"];
echo $_SESSION["emailInUse"];
?>
I'm trying to echo out the contents of the variables $accountExists and $emailInUse so that this is the result: Username already exists Email already in Use
However I'm getting an undefined index error.
 
    