Can anyone explain to me why I am getting duplicate messages instead of one? how can I change my code so that when I type a comment and press "Comment" button, it will only display one message instead of duplicates! When I have one comment boxes it doesn't show duplicate comments, but if I have more than one then it starts duplicating!
COMMENT.INC.PHP
include 'cdbh.inc.php';
function setComments($con) 
{
    if (isset($_POST['commentSubmit'])) {
        $uid = mysqli_real_escape_string($con,$_POST['uid']);
        $date = mysqli_real_escape_string($con,$_POST['date']);
        $message =  mysqli_real_escape_string($con,$_POST['message']);
        $sql = "INSERT INTO comments (uid, date, message) VALUES ('$uid','$date','$message')";
        $result = mysqli_query($con,$sql);
    }
}
function getComments($con)
{
    $sql = "SELECT * FROM comments";
    $result = mysqli_query($con,$sql);
    while ($row=mysqli_fetch_assoc($result)) {
        echo $row['uid'];
        echo ":"; 
        echo $row['message']."<br><br>";
    }
}
page code
<?php
    date_default_timezone_set('America/Los_Angeles');  
    include 'comment.inc.php';
    include("connection.php");
?>
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
            <link href="comment.css" rel ="stylesheet">
        </head>
        <body>
        <?php
            $sql="Select * from tbl_images";
            $result=mysqli_query($connection,$sql);
            while ($row=mysqli_fetch_array($result)) {
        ?>
        <img src="images/<?php echo $row['images_name'] ?>" width="200px" height="200px">
        <?php
            echo "<form method ='POST' action ='".setComments($con)."'>
                    <input type ='hidden' name ='uid' value='unknown'>
                    <input type ='hidden' name ='date' value='".date('Y-m-d H:i:s')."'>
                    <textarea name='message'></textarea>
                    <button type ='submit' name='commentSubmit'>Comment</button>
                </form>";
            }
            getComments($con);
        ?>
    </body>
</html>

 
    