gpt4 book ai didi

php - 表单数据未插入到 MySQL 表中

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

<分区>

我已经尝试了所有我能想到的方法,但我的表单中的数据没有插入到 MySQL 表中。这是我表格的相关部分:

<form id="masteringhtml5_form" action="send_formdata.php" method="POST">
<label for="heading" class="heading">Health Survey Form</label>
<fieldset class="fieldset_border">
<legend class="legend">Personal Information</legend>
<div>
<label for="name">Name</label><br>
<input type="text" name="Firstname" class="name txtinput" placeholder="First" autofocus>
<input type="text" name="Lastname" class="name txtinput" placeholder="Last">
</div>
<!-- other input fields here -->
<div class="submit">
<input type="submit" name="submit" class="submit_btn" value="Submit">
</div>
</form>

这是我的 php 文件“send_formdata.php”的相关部分:

<?php
mysqli_connect("localhost:3308","root","9gUCFpWmzh");
mysqli_select_db("personal_info");

if(isset($_REQUEST['submit'])) {
$errorMessage = "";
$Firstname=$_POST['Firstname'];
$Lastname=$_POST['Lastname'];
// other variables and validation here
if ($errorMessage != "" ) {
echo "<p class='message'>" .$errorMessage. "</p>" ;
} else {
//Inserting record in table using INSERT query
$insertTB="INSERT INTO `personal_info`.`personal`
(`Firstname`, `Lastname`, `Dob`, `Gender`, `Saddress`,
`Aaddress`, `City`, `State`, `Pincode`, `Country`, `Home`,
`Work`, `Email`) VALUES ('$Firstname', '$Lastname', '$Dob',
'$Gender', '$Saddress', '$Aaddress', '$City', '$State',
'$Pincode', '$Country', '$Home', '$Work', '$Email')";
mysqli_query($insertTB);
}
}
?>

数据库和表是正确的。我已使用“echo $insertTB”运行脚本,并在浏览器中生成完整的查询语句。

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