4

我有一个奇怪的问题,我无法理解。

我有以下表单,当我单击提交时,我没有获取或发布表单中的所有字段。只有两个字段被选中 - isnew=true action=object &submit=Start

<form name="newOffer" action="/auth/dashboard" method="post">
                                <td><?php echo form_hidden('isnew', 'true');?><?php echo form_hidden('action', 'object');?><input type="text" id="newOfferItem" placeholder="Offer Free Item" class="input-xlarge"></td>
                                <td><input type="text" id="newOfferText" placeholder="Offer Description" class="input-xlarge" rel="tooltip" title="Description How to get free item"></td>
                                <td><input type="text" id="newOfferFreeOn" placeholder="Stamps for free item" class="input-xlarge" rel="tooltip" title="Number only. Ex. 5"></td>
                                <td><span class="label label-danger">Inactive</span></td>
                                <td><?php $attributes = 'class = "btn btn-success"'; echo form_submit('submit', 'Start', $attributes);?></td>
                             </form>
4

2 回答 2

4

您需要为每个 INPUT 元素添加 NAME 属性 - 代替 ID 属性或添加到 ID 属性。

例如

<form name="newOffer" action="/auth/dashboard" method="post">
    <td>
        <?php echo form_hidden('isnew', 'true');?>
        <?php echo form_hidden('action', 'object');?>
        <input type="text" NAME="newOfferItem" id="newOfferItem" placeholder="Offer Free Item" class="input-xlarge">
    </td>
    <td>
        <input type="text" NAME="newOfferText" id="newOfferText" placeholder="Offer Description" class="input-xlarge" rel="tooltip" title="Description How to get free item">
    </td>
    <td>
        <input type="text" NAME="newOfferFreeOn" id="newOfferFreeOn" placeholder="Stamps for free item" class="input-xlarge" rel="tooltip" title="Number only. Ex. 5">
    </td>
    <td>
        <span class="label label-danger">Inactive</span>
    </td>
    <td>
        <?php $attributes = 'class = "btn btn-success"'; echo form_submit('submit', 'Start', $attributes);?>
    </td>
</form>
于 2013-04-25T16:43:10.677 回答
0

总是在元素中添加一个name属性。 这是给你的一个例子..input

索引.html

<form method="POST" action="process.php">
    <input type="text" name="username" value="">
    <input type="password" name="password" value="">
    <input type="submit" name="submit" value="login">
</form>

进程.php

<?php

// checking if submit is pressed

if (isset($_POST['submit'])) {

    // assigning posted values

    $username = $_POST['username'];
    $password = $_POST['password'];

    // testing

    echo $username . "<br>";
    echo $password;
}

?>
于 2013-04-25T16:48:00.200 回答