【发布时间】:2018-08-13 18:47:14
【问题描述】:
我想在使用 $_POST 设置我的 html 表单时获取文本输入 'name="quantity"' 的值,问题是每次我提交表单时都无法获得它的值! HTML :
<form method="POST" name="updateform">
<!-- the input text that i want to get it's value when the form is isset -->
<input type="text" name="quantity" value="<?php echo $row['quantite'] ?>" size="1" class="form-control" />
<!-- the input text that i want to get it's value when the form is isset -->
<a type="submit" name="updateu" data-toggle="tooltip" title="Update" class="btn btn-primary" href='cart.php?id=<?php echo $getid ?>&upt=<?php echo $row['idproduit']; ?>' ><i class="fa fa-clone"></i></a>
</form>
PHP:
//update commande
if (isset($_POST['updateform'])) {
$mdf = $_POST['quantity'];
echo $mdf;
}else{
echo "form not isset()";
}
//update commande
它显示“表单未设置”
请提供任何解决方案,谢谢
【问题讨论】:
-
这是一个错字问题。您不能依赖 HTML 标记标签作为输入。使用实际的“输入”。
-
@FunkFortyNiner 即使表单是 isset 我也能得到它的值
-
很可能是因为您(可能)使用 GET 数组在别处获取此
href='cart.php?id。 -
@FunkFortyNiner 这是一个购物车!所以我当用户输入他想要的数量并保存点击更新数量按钮时,我将他重定向到同一页面并传递命令 id,我得到用户使用 $_POST 更新的新数量,所以我可以更新它在数据库中,如果您理解我,请提供任何解决方案? ,非常感谢
-
这个问题的状态是什么? @JayBlanchard 为您提供了一个答案,对我来说,这似乎是一个/解决方案。如果已解决,则应将其标记为已解决。这里似乎是这样。