我正在尝试将我的表单插入到我的数据库中,但是“reden”输入只会在我在文本框中键入时输入。我的单选按钮的值似乎没有输入。我该如何解决?这是一个用于进行简单注册的文件。我的数据库中“reden”的 varchar 值为 (20),所以我不明白为什么它没有出现。它只是黑色的。
<?php
$Groep = $_POST['Groep'];
$reden = $_POST['reden'];
//$RDatum = $_POST[STR_TO_DATE('$$RDatum', '%m/%d/%Y')];
date_default_timezone_set('UTC');
$timestamp = strtotime($_POST['tijdstip']);
$tijdstip=date("Y-m-d", $timestamp);
if (!empty($Groep) || !empty($tijdstip) )
{
$host = "localhost";
$dbUsername = "root";
$dbPassword = "root";
$dbname = "gevuldetomaat";
//create connection
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if ($conn->connect_error) {
die("Connection failed: ". $conn->connect_error);
} else {
$INSERT ="INSERT INTO reservering (Tijdstip, reden, Groep) values(?, ?, ?)";
$stmt = $conn->prepare($INSERT);
$stmt->bind_param("sss",$tijdstip, $reden, $Groep);
$stmt->execute(); // Run the INSERT statement
if ($stmt->errno) { // Check for errors
die("Error in inserting: " . $stmt->error); // Print last error
}
else { // No errors
echo "New record inserted sucessfully"; // Success message
}
}
}
?>
这是我的html代码
<!DOCTYPE html>
<html
<head>
<title>De Gevulde Tomaat</title>
<meta charset="utf-8">
<link rel="stylesheet" href="Reservering.css">
</head>
<body>
<form action="Reservering.php" method="POST">
<table>
<tr>
<td style="color:white">GROEP :</td>
<td><input type="number" name="Groep" required></td>
</tr>
<tr>
<tr>
<td style="color:white">Reden :</td>
</tr>
<tr>
<td><input type="radio" name="reden" value="Verjaardag">Verjaardag</td>
<td style="color:white"><label for="Verjaardag">Verjaardag</label><br></td>
</tr>
米琪卡哇伊