首页 文章

当HTML表单被设置时,无法获取$ _POST变量值

提问于
浏览
-1

我希望得到文本输入'name =“quantity”'的值,当我的html表单是使用$ _POST设置时,问题是我每次提交表单时都无法获得它的 Value ! 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

它显示“形式不是isset”

任何解决方案,谢谢

1 回答

  • 5

    您不能使用锚标记作为表单的一部分,就像您在此处所做的那样:

    <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>
    

    链接永远不会成为post数组的一部分 . 您将需要一个名为 updateu 的提交输入,例如:

    <input type="submit" name="updateu" ...
    

相关问题