gpt4 book ai didi

php - Bootstrap 表单到数据库

转载 作者:太空宇宙 更新时间:2023-11-03 10:45:44 25 4
gpt4 key购买 nike

我创建了一个 Bootstrap 表单,并希望将表单中的数据包含到我的数据库中。我的问题是它不起作用,我不知道为什么。在我看来,一切都是正确的。我现在找了几个小时,但找不到问题。

您可以在这里找到我的表格:http://schulkantine.ccsolution.at/registration.php请不要看样式,我稍后要自定义。

这是我的 register.php!数据库连接正常。

<?php
// Create connection credentials
$db_host = 'localhost';
$db_name = 'DBNAME';
$db_user = 'DBUSER';
$db_pass = 'DBPASSWORD';

// Create mysqli object
$connect = new mysqli ($db_host, $db_user, $db_pass, $db_name);

// Error Handler
if ($connect->connect_error) {
printf ("Connection failed: %s\n", $connect->connect_error);
exit();
}
?>

<?php
// Check if form is submitted
if (isset ($_POST['submit'])) {
$anrede = mysqli_real_escape_string ($connect, $_POST['anrede']);
$vorname = mysqli_real_escape_string ($connect, $_POST['vorname']);
$nachname = mysqli_real_escape_string ($connect, $_POST['nachname']);
$strasse = mysqli_real_escape_string ($connect, $_POST['strasse']);
$plz = mysqli_real_escape_string ($connect, $_POST['plz']);
$ort = mysqli_real_escape_string ($connect, $_POST['ort']);
$email = mysqli_real_escape_string ($connect, $_POST['email']);
$telefon = mysqli_real_escape_string ($connect, $_POST['telefon']);

// Validate Input
$query = mysql_query("INSERT INTO user (anrede, firstname_parent, lastname_parent, street_parent, plz_parent, city_parent, email, phonenumber_parent)
VALUES ('$anrede', '$vorname', '$nachname', '$strasse', '$plz', '$ort', '$email', '$telefon')") or die(mysql_error());
}
?>

希望有人能帮助我并告诉我我的错误是什么!

最佳答案

尝试改变

INSERT INTO user (anrede, firstname_parent, lastname_parent, street_parent, plz_parent, city_parent, email, phonenumber_parent) VALUES ('$anrede', '$vorname', '$nachname', '$strasse', '$plz', '$ort', '$email', '$telefon')"

INSERT INTO `user` (`anrede`, `firstname_parent`, `lastname_parent`, `street_parent`, `plz_parent`, `city_parent`, `email`, `phonenumber_parent`) VALUES ('$anrede', '$vorname', '$nachname', '$strasse', '$plz', '$ort', '$email', '$telefon')"

关于php - Bootstrap 表单到数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32153030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com