【问题标题】:PHP isset not accepting form namePHP isset 不接受表单名称
【发布时间】:2021-06-18 16:23:04
【问题描述】:

当我检查是否已设置时,我在尝试使用隐藏输入字段识别我的表单时遇到问题。不知道是因为我在循环中运行表单还是什么。我确实知道,当我为循环中的任何字段单击提交时,隐藏字段的值正在正确注册,它只是以某种方式'form1'没有注册为 isset。有什么想法吗?

<?php
if(isset($_POST['form1']))
    {
    echo $_POST['cid'];
    } else {echo "nope!";} 
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" name="form1">
// gets array
$listchars = $user->getCharacterList($_SESSION['user_id']);
// loops through array 
foreach($listchars as $chardata){
 echo $chardata['name']; ?>
<input type="hidden" name="cid" value="<?php echo $chardata['cid'];?>">
<input type="submit" name="submit" value="submit">
<?php } ?>
</form>

【问题讨论】:

    标签: php html arrays hidden-field


    【解决方案1】:

    表单名称未提交

    使用

    &lt;input type="submit" name="form_name"&gt;

    &lt;input type="hidden" name="form_name"&gt;

    【讨论】:

      猜你喜欢
      • 2019-08-10
      • 2019-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多