The issue I'm experiencing is the code below seems to clone (duplicate) the form or any other HTML that loads on the page .
The first time I load the page the form appears as normal however when I type in the search text-box and delete all the characters the form displays twice (or any other HTML I place on the page)
How can it be possible to load the page without the form(s) or any other of the page contents repeated please?
<?php
    include('..\db.php');
    $con = mysqli_connect($dbsrvname, $dbusername, $dbpassword, $dbname);
    $q1 = mysqli_query($con, "SELECT * FROM tbl1 username");
    $data = "";
    // if the search is true 
    if(isset($_POST['search']))
    {
        // 
        $var = $_POST['search'];
        if ($query = mysqli_query($con,"SELECT username FROMtbl1 WHERE username LIKE '%$var%'"))
        {
            // possible creating duplicate results 
            while($row = mysqli_fetch_array($query))
            {
                $data .= '<div>' . $row['username'] . '</div>';  
            }
            echo $data;
        }
    }
    else
    {
    }
?>
<HTML>
<head>
    <script src="https://code.jquery.com/jquery-3.0.0.js" integrity="sha256-jrPLZ+8vDxt2FnE1zvZXCkCcebI/C8Dt5xyaQBjxQIo=" crossorigin="anonymous"></script>
    <script>
        $(function() {
            $('.input').keyup(function() {
                var a = $('.input').val();
                $.post('livesusers.php', { "search": a }, function(data) {
                    $('#display').html(data);
                });
            });
        });
    </script>
</head>
<body>
    // form to input text  and search
    <h1>Search For User</h1>
    <form action= "livesusers.php" method='POST'>
        <input type="text" name="search" class='input'>
    </form>
    <div id='display' style='margin-top: 100px'></div>
</body>

 
     
    