【发布时间】:2018-01-15 22:18:02
【问题描述】:
我有这张表,它处理所有用户反馈,我在这张表上有这个 id 列。我不确定它的目的是什么。我也没有在代码中看到任何 id。
PS:我刚从网上得到代码。
<?php
require_once ('database.php');
if (isset($_POST['send'])) {
$full_name = $_POST['full_name'];
$email = $_POST['email'];
$website = ($_POST['website']);
$message = ($_POST['message']);
{
$database->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$insert_query = "INSERT INTO tbl_feedback (full_name, email, website, message)
VALUES (?, ?, ?, ?)";
$insert = $database->prepare($insert_query);
$insert->execute(array($full_name, $email, $website, $message));
echo "<script>alert('Successfully sent!'); window.location='feedback.php'</script>";
}
}
?>
【问题讨论】:
-
请阅读主键。它可能设置为自动增量。检查表结构
-
通常使用自增主键,如果您不通过 INSERT 语句将特定值放入其中,它们是由数据库生成的。
-
我认为您接受了错误的答案...@Gordon Linoff 的回答与您的问题更相关。