I have a little problem with my PHP code and database. Every time i refresh the page, a new empty row is being added to the database also when i open the page, what is the problem?
<?php
if (isset($_POST)) {
    $con = mysql_connect("localhost","dwarfmaster","");
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("my_dwarfmaster", $con);
    $name = $_POST['name'];
    $release_year = $_POST['release_year'];
    $publisher = $_POST['publisher'];
    $genre = $_POST['genre'];
    $sql = "INSERT INTO gamelist (name, release_year, publisher, genre)
        VALUES
        ('$_POST[name]','$_POST[release_year]',
        '$_POST[publisher]','$_POST[genre]')";
    if (!mysql_query($sql, $con)) {
        die('Error: ' . mysql_error());
    }
    echo "1 record added";
    mysql_close($con);
}
?>
 
     
     
     
     
    