<div class ="content">
<form action="" method="POST">
<table border='1'>
<tr>
<td>Toilet:</td>
<td><input placeholder="Toilet" type="text" name="Toilet"
value="<?php isset ($_POST['Toilet'])?$_POST['Toilet']:"";?>"/></td>
</tr>
<tr>
<td>Art. nr:</td>
<td><input placeholder="Artikel nr." type="text" name="Artnr"
value ="<?php isset ($_POST['Artnr'])?$_POST['Artnr']:"";?>"/></td>
</tr>
<tr>
<td>Art. nr fabrikant:</td>
<td><input placeholder="Artikel nr. fabrikant" type="text" name="ArtNrFabrikant"
value ="<?php isset ($_POST['ArtNrFabrikant'])?$_POST['ArtNrFabrikant']:"";?>"/></td>
</tr>
</table>
<input type="submit" name="AddToilet" value ="WC Toevoegen"/> <br />
<?php
if(isset($_POST ['AddToilet']))
{
if(!empty($_POST['Toilet'])&& !empty($_POST['Artnr'])&& !empty($_POST['ArtnrFabrikant']))
{
$result = $db->exec("INSERT INTO Toilet(Toilet, Artnr, ArtnrFabrikant)
VALUES('"
.$_POST['Toilet']."','"
.$_POST['Artnr']."','"
.$_POST['ArtNrFabrikant'].
"')");
$insertId = $db->lastInsertId();
echo "de ". $_POST['Toilet']. " is toegevoegd!";
}
else
{
echo "Vul alles in<br />";
}
}
?>
</form>
</div>
我的 IF 语句有问题:
if(!empty($_POST['Toilet']) && !empty($_POST['Artnr']) && !empty($_POST['ArtnrFabrikant']))
如果我运行这段代码,它会跳转到其他地方,即使我填写了 3 个文本字段。
当我删除 if 语句的最后一部分时:
&& !empty($_POST['ArtnrFabrikant']))
它进入 if 语句。所以我的ArtNrFabrikant有问题。但我不知道有什么问题。
请帮帮我。