Html表单发布,没有传递数据

时间:2012-10-09 00:04:00

标签: php html forms post

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

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

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

2 个答案:

答案 0 :(得分:10)

您应该使用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'];
?>

答案 1 :(得分:5)

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

<input type="text" name="myinput">
然后,Php将使用这些名称构建$ _POST数组。