来自Form的PHP _POST数据

时间:2016-03-11 19:10:22

标签: php mysql

我有这个表单,我正在使用PHP创建。表单元素的名称是数字

<form method="post" action="keywords.php">
    <?php
    echo $question
    ?>
    </div>
    <div class="panel-body">
    <?php
    foreach ($orderexplode as $o) 
    {
        switch ($o) {
            case 0:
                print(" " . "<label>" . $presetwords[$i] . "</label>" . " ");
                $i++;
                break;
            case 1:
                print(" " . "<input type='text' class='form-control' name='$k' id ='$k'placeholder=" . $responsewords[$k] . ">" . " ");
                $k++;
                echo $k;
                break;
        }
    }
    ?>
    <br>
    <button type='submit' class='btn btn-info'>Submit</button>
</form>

我如何获取每个输入框的值,我想检查它是否与$exploded字符串匹配?

$string = "Hello How Are You"
$explodedstring = explode(" ",$string)

1 个答案:

答案 0 :(得分:0)

您正在尝试使用数组索引。您需要使用索引:

<?php
foreach ($orderexplode as $k => $o) 
{
    print(" " . "<label>" . $k . "</label>" . " ");
    print(" " . "<input type='text' class='form-control' name='" . $k . "' id ='" . $k . "'placeholder=" . $o . ">" . " ");
}
?>