Wamp数据库不会更新所有字段

时间:2014-04-16 12:02:08

标签: php mysql sql mysqli

我在用户输入的WAMP数据库中插入数据:

PHP

<?php
$con=mysqli_connect("127.0.0.1","beni","2155","visitbulgaria");
// Check connection
if (mysqli_connect_errno())
{
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

// escape variables for security
$forename = mysqli_real_escape_string($con,$_POST['Forename']);
$surname = mysqli_real_escape_string($con,$_POST['Surname']);
$email = mysqli_real_escape_string($con,$_POST['Email']);
$username  = mysqli_real_escape_string ($con,$_POST['Username']);
$password  = mysqli_real_escape_string ($con,$_POST['Password']);

$sql="INSERT INTO `customer`(`Forename`, `Surname`, `Email`, `Username`, `Password`)
VALUES ('$forename', '$surname', '$email', '$username', '$password')";

if (!mysqli_query($con,$sql))
{
  die('Error: ' . mysqli_error($con));
}
echo "1 record added";

mysqli_close($con);
?>

HTML

<html>
    <body>
        <form action="insert.php" method="post">
            Firstname: <input type="text" name="Forename">
            Lastname: <input type="text" name="Surname">
            Email: <input type="text" name="Email">
            username: <input type="text" name="Username">
            pass: <input type="text" name="Password">
            <input type="submit">
        </form>
    </body>
</html>

这里发生的是提交它确实有效但当我在 phpMyAdmin 中查看数据库时,它只添加了前三条记录(forenamesurnameemail然后usernamepassword字段留空,我不知道如何修复它以及为什么要这样做。

0 个答案:

没有答案