unable to echo PHP POST data to HTML code

I have added some HTML and PHP code, in my if isset array i defined some variable, and now i want to print $uname variable in html h1 tag, but when i set $uname to h1 tag and echo , i get a undefined variable error, now i want to solve this. can anyone answer and rewrite a sample code for me?

PHP Code

if(isset($_POST['submit'])){ 
    $uname=$_POST['name']; 
    $email=$_POST['email']; 
    $message=$_POST['msg']; 

    $sql = "INSERT INTO `users`(`name`, `email`,`message`) VALUES ('$uname','$email','$message')";


    if (mysqli_query($conn, $sql)) {
        echo json_encode(array("statusCode"=>200)); 
    }
    else { 
        echo json_encode(array("statusCode"=>201)); 
    } 
    mysqli_close($conn);
}

HTML Code

<link rel="stylesheet" href="style.css">


    <div class="message" style="display: none;">

        <!--Model Popup starts-->


            <div class="modal-content">


                <div class="modal-body">

                    <div class="thank-you-pop">
                        <img src="http://goactionstations.co.uk/wp-content/uploads/2017/03/Green-Round-Tick.png" alt="">
                        <h1>Hi <?php echo $uname; ?>, Thank You!</h1>



                        <h3 class="cupon-pop">Your Message is received and I will contact you soon.</h3>

                    </div>

                </div>
            </div>  
    </div>