所以你们都可以看到这是造成问题的一小部分形式。
我通过下拉列表获取表单中的所有记录,并希望将所选结果发送到数据库。 提交记录后插入正确的除了这两个:$ locatie = $ _ POST [" locatie"];和$ vestiging = $ _POST [" vestiging"]; 插入为NULL。
我希望它能够发送在表单中选择的记录。 有人能帮助我吗?
<form name="nieuwTicket" action="nieuwTicketNieuwKlant.php" method="POST">
<label class="hidden02">locatie:</label>
<select name="locatie" class="hidden2">
<option value = "">---Select---</option>
<?php
$ophaall = "SELECT * FROM locatie ";
$resultl = mysqli_query($connectie, $ophaall);
while ($l = mysqli_fetch_assoc($resultl)) {
echo "<option value='{" . $l['locatieId'] . "}'>" . $l['locatieId'] . " " . $l['locOmschrijving'] . "</option>";
}
?>
</select><br>
<label class="hidden02">vestiging:</label>
<select name="vestiging" class="hidden2"> <!-- Disabled, gaan we nog niets mee doen-->
<option value = "">---Select---</option>
<?php
$ophaalv = "SELECT * FROM vestigingen ";
$resultv = mysqli_query($connectie, $ophaalv);
while ($v = mysqli_fetch_assoc($resultv)) {
echo "<option value='{" . $v['vestigingId'] . "}'>" . $v['vestigingId'] . " " . $v['vesOmschrijving'] . "</option>";
}
?>
</select><br>
<input type="submit" name="submit1" value="invoeren" class="hidden" />
</form>
<!--submit insert to database-->
<?php
$locatie = $_POST["locatie"];
$vestiging = $_POST["vestiging"];
if (isset($_POST['submit1'])) {
// nieuwe klant
$insertklant = $connectie->prepare("INSERT INTO klant (klantId, klantAchternaam, klantNaam, klantTel,
klantAdres, klantPostc, klantStad, klantEmail, instantieId, locatieId)
VALUES ('',?,?,?,?,?,?,?,?,?)");
if ($insertklant) {
$insertklant->bind_param('sssssssii', $achternaam, $naam, $tel, $adres, $postcode, $stad, $email, $locatie, $vestiging);
if ($insertklant->execute()) {
echo ' klant gemaakt!';
}
}
?>