这段代码有些错误,因为当我按下提交按钮时,这个代码块中的代码没有被执行。这是代码:
if(isset($_POST["form"])) {
if (Form::isValid($_POST["form"])){
include 'config_php/insert_lead.php';
} else{
header("Location: " . $_SERVER["PHP_SELF"]);
exit();
}
}
这是表单的一小部分:
<form action="index.php?s=2468" id="multiphase" method="post" class="form-horizontal">
<fieldset>
<input type="text" class="form-control shadow" name="first_name" required="" placeholder="Voornaam:" id="multiphase-element-22">
<input type="text" class="form-control shadow" name="last_name" required="" placeholder="Achternaam: " id="multiphase-element-23">
<input type="email" class="form-control shadow" name="email1" required="" placeholder="E-mailadres:" id="multiphase-element-28">
<input type="submit" value="Submit" name="submit" class="btn btn-primary" id="multiphase-element-29">
</fieldset>
</form>
表单是使用 PFBC 生成的另一件事
没有名为"form"的帖子值,因此您应该设置一个要在提交中查找的帖子值。
请注意,我还在 Form::isValid(( 检查中使用了整个 POST 数组。
.PHP:
if(isset($_POST["postback"])) {
$valid = true;
if (Form::isValid($_POST)){
include 'config_php/insert_lead.php';
} else{
header("Location: " . $_SERVER["PHP_SELF"]);
exit();
}
}
.HTML:
<form action="index.php?s=2468" id="multiphase" method="post" class="form-horizontal">
<fieldset>
<input type="text" class="form-control shadow" name="first_name" required="" placeholder="Voornaam:" id="multiphase-element-22">
<input type="text" class="form-control shadow" name="last_name" required="" placeholder="Achternaam: " id="multiphase-element-23">
<input type="email" class="form-control shadow" name="email1" required="" placeholder="E-mailadres:" id="multiphase-element-28">
<input type="hidden" name="postback" value="1">
<input type="submit" value="Submit" name="submit" class="btn btn-primary" id="multiphase-element-29">
</fieldset>
</form>
在你的代码中$_POST["form"]
是你做的错......
如果您使用的是$_POST["form"]
那么这意味着您已将任何输入字段命名为">表单",而我在代码中没有看到......
因此,您应该使用您使用的任何输入名称而不是$_POST["form"]
...我建议使用.. $_POST["submit"]
而不是$_POST["form"]
因为您已经将提交输入字段命名为提交...看看是否有帮助
更改form
tor submit
:
<?php
if(isset($_POST["submit"])) {
if (Form::isValid($_POST["form"])){
include 'config_php/insert_lead.php';
} else{
header("Location: " . $_SERVER["PHP_SELF"]);
exit();
}
}
if
将被执行,但您仍然会在下一个if
(Form::isValid($_POST["form"])
(中遇到问题,我不知道isValid
是如何工作的,但$_POST["form"]
不存在。您可以逐个验证所有输入。