发送时没有参数

时间:2014-10-24 06:01:39

标签: html forms http post

我有以下HTML代码。我不知道为什么POST没有参数发送(我检查了参数是不是用firefox调试器发送的):

<div class="modal fade"id="myModal"tabindex="-1"role="dialog"aria-labelledby="myModalLabel"aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button"class="close"data-dismiss="modal">
                    <span aria-hidden="true">&times;</span>
                    <span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title"id="myModalLabel">Add opinion</h4>
            </div>
            <form role="form" action="api/sendEntry" method="post">
            <div class="modal-body">
                    <div class="form-group">
                        <label for="user_message">The following: </label>
                        <input type="text" class="form-control" id="user_message" placeholder="In next...">
                        <label for="user_date">Until: </label>
                        <input type="date" class="form-control" id="user_date">
                    </div>
            </div>
            <div class="modal-footer">
                <button type="submit"class="btn btn-default">Submit</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">Close </button>
            </div>
            </form>
        </div>
    </div>
</div>

我怀疑嵌套的输入字段可能与它有关,但我需要嵌套它们才能有正确的格式。

2 个答案:

答案 0 :(得分:1)

您需要为输入字段分配name。例如:

<input type="text" class="form-control"
    id="user_message" name="user_message" placeholder="In next..." />

表单数据作为名称/值对发布。如果您未提供name属性,则不会发布任何内容。

作为旁注,我还建议您正确关闭input代码。

答案 1 :(得分:0)

<div class="modal fade"id="myModal"tabindex="-1"role="dialog"aria-labelledby="myModalLabel"aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button"class="close"data-dismiss="modal">
                    <span aria-hidden="true">&times;</span>
                    <span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title"id="myModalLabel">Add opinion</h4>
            </div>
            <form role="form" action="api/sendEntry" method="post">
            <div class="modal-body">
                    <div class="form-group">
                        <label for="user_message">The following: </label>
                        <input type="text" class="form-control" id="user_message" placeholder="In next..." name="user_message">
                        <label for="user_date">Until: </label>
                        <input type="date" class="form-control" id="user_date" name="user_date">
                    </div>
            </div>
            <div class="modal-footer">
                <button type="submit"class="btn btn-default">Submit</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">Close </button>
            </div>
            </form>
        </div>
    </div>

使用$_POST['user_date']$_POST['user_message']

接收您的数据