2

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

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

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

这似乎是表单本身的问题,好像表单设置为获取,它只是输入带有问号的脚本,blueprints/add?,意味着根本没有传递任何数据。

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

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

4

2 回答 2

14

您应该使用 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'];
?>
于 2012-10-09T00:11:17.390 回答
6

您需要将 name 属性添加到输入并选择元素

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

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

于 2012-10-09T00:10:18.907 回答