<?php
    if ($username){
        if ($check){
            $data_array = array(
                'username' => $check[0]->username
            );
            $_SESSION['username'] = $check[0]->username;
            echo json_encode($data_array);
        }
        if ($check == NULL){
            $data_failed = array(
                'Error' => "Username is not valid!",
                'code' => 505
            );
            echo json_encode($data_failed);
        }
    }
        
?>