search – How to fetch Email addres of an author via ID?

I want to make an HTML form which will have an input field to fill in the ID of the user. Then I want to pass the value into a php code such that the email address associated with that user ID is displayed. However, I am new to WP and don’t know how to do it correctly.

I made a new php file in the root folder of my WP directory and put in this code and tried by browsing the file, but it didn’t work.

<?php
$field = 53;
$value = 53;
function get_user_by( $field, $value ) {
$userdata = WP_User::get_data_by( $field, $value );

if ( ! $userdata ) {
    return false;
}

$user = new WP_User;
$user->init( $userdata );

var_dump($user);
}
?>

I searched in the web as well, but couldn’t find anything of this sort? Can someone guide me through this?