【问题标题】:Html form posting, no data passed on [duplicate]Html表单发布,没有数据传递[重复]
【发布时间】:2012-09-29 06:13:01
【问题描述】:

这个问题我已经坐了一段时间了,似乎无法弄清楚代码有什么问题。

问题是没有数据从表单发布到脚本。

<div class="mws-panel-body">
    <form class="mws-form" action="blueprints/add" method="post" id="pForm">
        <div class="mws-form-inline">
            <div class="mws-form-row">
                <label>Blueprint name</label>
                <div class="mws-form-item small">
                    <input type="text" class="mws-autocomplete mws-textinput" id="pName" value="" />
                    <div>The name of the blueprint, search completion is enabled.</div>
                </div>
            </div>
            <div class="mws-form-row">
                <label>Hangar</label>
                <div class="mws-form-item micro">
                    <select id="pHangar">
                        <option value="0" selected>Personal</option>
                        <option value="1">Corporation</option>
                    </select>
                    <div>Indicates who the blueprint belongs to.</div>
                </div>
            </div>
            <div class="mws-form-row">
                <label>State</label>
                <div class="mws-form-item micro">
                    <select id="pState">
                        <option value="1" selected>Original</option>
                        <option value="0">Copy</option>
                    </select>
                    <div>The state of the blueprint, be it original or a copy.</div>
                </div>
            </div>
            <div class="mws-form-row">
                <label>Productions runs</label>
                <div class="mws-form-item small">
                    <input type="text" class="mws-textinput" id="pRuns" value="0" />
                    <div>The number of production runs left on copy.</div>
                </div>
            </div>
            <div class="mws-form-row">
                <label>Material efficiency</label>
                <div class="mws-form-item small">
                    <input type="text" class="mws-textinput" id="pME" value="0" />
                    <div>The current material efficiency level of the blueprint.</div>
                </div>
            </div>
            <div class="mws-form-row">
                <label>Production efficiency</label>
                <div class="mws-form-item small">
                    <input type="text" class="mws-textinput" id="pPE" value="0" />
                    <div>The current production efficiency level of the blueprint.</div>
                </div>
            </div>
        </div>
        <div class="mws-button-row">
            <input type="submit" value="Add blueprint" class="mws-button blue" />
            <input type="reset" value="Reset" class="mws-button gray" />
        </div>
    </form>
</div>

好像是表单本身的问题,好像表单设置为get,只是进入脚本只带一个问号,blueprints/add?,表示根本没有数据传入。

任何指针或建议将不胜感激。

如果有帮助,我的平台是 PHP。

【问题讨论】:

  • 请求通过modrewrite条件,重写到PHP页面
  • 哇我觉得很傻,完全忘记了!怎么会这样:|请发布它作为答案。
  • 可能是因为我最近从JS post转到了html post。

标签: php html forms post


【解决方案1】:

您应该使用 input 的 name 属性将数据发送到 PHP post 脚本。示例:

表格:

<form action="add.php" method="post">
    <input type="text" name="firstname" />
</form>

脚本(add.php):

<?php
//print the $_POST['firstname'] variable
echo $_POST['firstname'];
?>

【讨论】:

  • 从来不知道这个。这是 HTML 表单的工作原理吗?
【解决方案2】:

您需要在输入中添加名称属性并选择元素

<input type="text" name="myinput">

然后,Php 将使用这些名称构建您的 $_POST 数组。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-22
    • 2015-12-05
    • 2017-04-18
    • 2016-03-23
    • 2016-07-16
    • 2018-05-23
    • 1970-01-01
    相关资源
    最近更新 更多