【问题标题】:HTML form post method isn't functioningHTML 表单发布方法不起作用
【发布时间】:2020-06-09 03:58:31
【问题描述】:

这可能是非常简单的事情,但是我觉得我的大脑因为盯着电脑屏幕这么久而被煎炸了,所以任何指针都将不胜感激......

我似乎无法让$_POST 处理我的表单。当我将方法切换到 GET 时 - 它工作正常,但我不想重复从 URL 中提取表单数据,因为它是一个相当长的表单并且会采取额外的步骤等。

我的表单数据:

<form action="<?= site_url() ?>shop/mock/form/<?= esc($first['gtin']); ?>" name="myForm" method="post">

    <div class="p-3 p-lg-5 border">

        <div class="form-group row">
            <div class="col-md-12">
                <label for="brand_name" class="text-black">Brand Name </label>
                <input type="text" value="<?= esc($_POST['brand_name']); ?>" class="form-control" id="brand_name" name="brand_name">
            </div>
        </div>

        <?php if (isset($_POST['brand_name'])): ?>

        <div class="form-group row">
            <div class="col-md-12">
                <label for="subbrand_name" class="text-black">Subbrand Name </label>
                <input type="email" value="<?= esc($_POST['subbrand_name']); ?>" class="form-control" id="subbrand_name" name="subbrand_name" placeholder="">
            </div>
        </div>

        <?php endif; ?>

    </div>
</form>

我唯一能想到的是,我每次都将表单发送回同一个地址,并尝试从最新提交中获取 $_POST 数据,并重新填充输入值,以便表单构建每次提交并显示下一个输入等。var_dump($_POST) 每次都显示一个空数组。

我哪里出错了?

【问题讨论】:

  • 重定向后不再是 POST 请求。 POST 数据丢失。

标签: php html forms post http-post


【解决方案1】:

如果你想在表单中接收otp然后action为空,如果你想从其他action接收,你必须把值放入$_SESSION

【讨论】:

    猜你喜欢
    • 2015-08-21
    • 2018-12-06
    • 1970-01-01
    • 2013-03-23
    • 2018-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-28
    相关资源
    最近更新 更多