PHP:表单提交问题


PHP:Issue with form submit

我的页面中有一个表,在表的每一行中,我都有每个商品的一些值,在行的最后一列中,我有"编辑"按钮,它将数据发送到其他php页面。

为此,请使用下面的(PHP)FORM并尝试在同一页面上发布值。我的问题是我无法检索下面评论语句中给出的值。

如果我只使用HTML表单,它也可以正常工作,但我不想使用,因为表很大,信息可以很容易地在资源管理器页面上的"查看代码"中看到,而且信息几乎不保密。所以我想只使用PHP表单。

下面是我的代码。

<FORM METHOD="post" ACTION="inventory.php">
    <?php '<input name="number" type="hidden" id="number"  value="'. $list[$i] .'">'?>
    <?php '<input name="model" type="hidden" id="model"  value="'.$model[$i].'"> '?>
    <?php '<input name="details" type="hidden" id="details"  value="'. $detail[$i].'">'?>
    <?php '<input name="type" type="hidden" id="type" value="'.$type[$i].'">'?>
    <?php echo '<button type="submit" class="button" value="'.$list[$i] .'" name="edit">Edit</button>';?> </FORM> 
if (isset ($_POST['edit']))  
{
    echo $_POST['edit'];               // Able to retrieve value of number (In chrome explorer), In (IE) it just displays as 'Edit'
    echo $_POST['number'];             // Not able to retrieve any value for this
    echo $model=$_POST['model'];       // Not able to retrieve any value for this
    echo $details=$_POST['details'];   // Not able to retrieve any value for this
    echo $type=$_POST['type'];         // Not able to retrieve any value for this
}

您还没有回显您的输入框,它是如何呈现的

例如你应该写

<?php echo '<input name="number" type="hidden" id="number"  value="'. $list[$i] .'">'; ?>

而不是

 <?php '<input name="number" type="hidden" id="number"  value="'. $list[$i] .'">'?>
<form method="post" action="inventory.php">
    <input name="number" type="hidden" id="number"  value="<?php echo $list[$i]; ?>">
   <input name="model" type="hidden" id="model"  value="<?php echo $model[$i];?>"> 
   <input name="details" type="hidden" id="details"  value="<?php echo $detail[$i]; ?>">
    <input name="type" type="hidden" id="type" value="<?php echo $type[$i]; ?>">
    <input type="submit" class="button" value="Edit" name="edit">
 </form> 
if (isset ($_POST['edit']))  
{
echo $_POST['number']; //Not able to retrive any value for this
echo $model=$_POST['model'];//Not able to retrive any value for this
echo $details=$_POST['details'];//Not able to retrive any value for this
echo $type=$_POST['type'];//Not able to retrive any value for this
}

真的,伙计,你应该从头开始学习php。