无法通过 PHP 将新数据插入数据库

Unable to insert new data into database via PHP

我无法在用户提交表单后将新数据存储到数据库中。我通过 phpMyAdmin 检查数据库 table,但我没有看到任何新数据。谁能告诉我代码中的错误。

HTML代码 (listing.html):

<html>
    <form action="confirm_listing.php" method="POST">
        <input name="Firstname" placeholder="Firstname">
        <input name="Lastname" placeholder="Lastname">
        ...
        <input type="submit" value="Submit">
    </form>
</html>

php代码 (confirm_listing.php):

<?php
    $firstname = $_POST['Firstname'];
    $lastname = $_POST['Lastname'];
    $address = $_POST['Address'];
    $suburb = $_POST['Suburb'];
    $city = $_POST['City'];
    $type = $_POST['Type'];
    $room = $_POST['Room'];
    $floorArea = $_POST['Floor'];
    $landArea = $_POST['Land'];
    $price = $_POST['Price'];
    $contact = $_POST['Contact'];
    $active = "1";

    $server = "localhost";
    $dbusername = "root";
    $dbpassword = "";
    $dbname = "summitrealestatedb";

    $connection = mysqli_connect($server, $dbusername, $dbpassword, $dbname);

    if (!$connection) {
        die("Connection failed: " . mysqli_connect_error());
    }

    $sql = "INSERT INTO property (firstname, lastname, address, suburb, city, type, room, floor, land, price, contact, active) VALUES ('$firstname', '$lastname', '$address', '$suburb', '$city', '$type', '$room', '$floorArea', '$landArea', '$price', '$contact', '$active');";
    mysqli_query($connection, $sql);

    mysqli_close($connection);
?>

这里是 a picture 它目前在数据库中的样子 table:

而不是

<?php
    $firstname = $_POST['Firstname'];
    $lastname = $_POST['Lastname'];
?>

使用

<?php
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
?>


使用您分配给名称而不是占位符的名称

尝试打印插入错误

 mysqli_query($connection, $sql) or die(mysqli_error($connection));